drop-down menu in uitable

21 visualizaciones (últimos 30 días)
aldo
aldo el 13 de Dic. de 2023
Editada: Voss el 13 de Dic. de 2023
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 ?

Respuesta aceptada

Voss
Voss el 13 de Dic. de 2023
Editada: Voss el 13 de Dic. de 2023
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;

Más respuestas (0)

Categorías

Más información sobre Industrial Statistics en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by