The selected content of popup menu created in a column of uitable does not hold

5 Ansichten (letzte 30 Tage)
I have created a uitable with its last column has a popup menu in each cell. But whenever I select the content of any menu it does not hold (the cell stays blank). The code is
moves = [1:Dynamic_states(c),]';
loads = zeros(size(moves));
strokes = Strokes{c,1}';
start_time = zeros(size(moves));
duration = Durations{c,1}';
mode = {'idle' 'sleep' 'off'};
tabledata =[moves loads strokes start_time duration];
columnname = {'Move #', 'Load kg', 'Strokes mm', 'Start time', 'Duration sec','Mode'};
columnformat = {'char', 'short', 'short', 'short', 'short', mode};
columneditable = [false true true true true true];
handles.Load_Data = uitable('Parent',AppTab,'Units','normalized','Position',[0.5 0.438 0.4913 0.3],'ColumnWidth','auto','Data', tabledata,'ColumnName', columnname,'ColumnFormat', columnformat,'ColumnEditable', columneditable,'RowName',[] ,'BackgroundColor',[.7 .9 .8],'ForegroundColor',[0 0 0]);
Note: The creation of the uitable is inside a for loop so please avoid using functions to solve this problem
  3 Kommentare
Jan
Jan am 8 Mär. 2017
Bearbeitet: Jan am 8 Mär. 2017
@Adam: The cell in the ColumnFormat create the popup menus in a uitable.
I do not see a reason to avoid a function to solve the problem. You can call functions from inside loops without any problems.
Adam
Adam am 8 Mär. 2017
Ah yes, I see now. I missed the mode line. It's a while since I've created a uitable!

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Jan
Jan am 8 Mär. 2017
Bearbeitet: Jan am 8 Mär. 2017
When I run you code and select an entry in the popup menu, Matlab shows the warning:
Warning: Table data is not editable at this location.
A guess: The Mode is missing in the tabledata. Try this:
mode = {'idle' 'sleep' 'off'};
modedata = cell(size(moves));
modedata(:) = {'idle'}; % Default value
tableValue = num2cell([moves, loads, strokes, start_time, duration]);
tableData = cat(2, tableVlaue, modedata);
Now the popups have default values and can be edited.

Weitere Antworten (0)

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by