drop-down menu in uitable

19 次查看(过去 30 天)
aldo
aldo 2023-12-13
编辑: Voss 2023-12-13
pl=struct2table(app.Preset);
app.Preset_UITable.Data=pl;
app.Preset_UITable.ColumnName = pl.Properties.VariableNames;
RankMode=Function_Categorical_Struct("RankingMode");
cat = categories(RankMode);
colu={'char' {cat{:}} };
app.Preset_UITable.ColumnFormat=colu;
i receive this error:
Warning: 'ColumnFormat' value has no effect when 'Data' value is a table array.
%{
RankMode =
6×1 categorical array
Descending Net Profit
Ascending Net Profit
Descending historical MaxDD
Ascending historical MaxDD
Descending NetProfit/MaxDD ratio
Ascending NetProfit/MaxDD ratio
%}
How do I open the menu with the menu below by pressing the button ?

采纳的回答

Voss
Voss 2023-12-13
编辑:Voss 2023-12-13
As the warning suggests, if you want to use ColumnFormat your Data can't be a table. Try using a cell array for Data, as in:
pl = struct2table(app.Preset);
app.Preset_UITable.Data = table2cell(pl);
Then you can set ColumnFormat to include a cell array of chars representing the items in a drop-down menu.
I'm not sure how many columns your table has (the screenshot shows 4, but the ColumnFormat/colu you define has 2) nor which column is intended to contain the drop-down menus. Make sure ColumnEditable is set to true on the drop-down column. You should avoid naming a variable cat, since that's the name of a built-in function.
app.Preset_UITable.ColumnName = pl.Properties.VariableNames;
RankMode = Function_Categorical_Struct("RankingMode");
cats = categories(RankMode);
% 4 columns, 3rd is drop-downs; adjust as needed:
colu = [{'char'} {'char'} {cats.'} {'char'}];
app.Preset_UITable.ColumnFormat = colu;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Industrial Statistics 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by