The selected content of popup menu created in a column of uitable does not hold
2 views (last 30 days)
Show older comments
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 Comments
Adam
on 8 Mar 2017
Ah yes, I see now. I missed the mode line. It's a while since I've created a uitable!
Accepted Answer
Jan
on 8 Mar 2017
Edited: Jan
on 8 Mar 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.
More Answers (0)
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!