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

3 次查看(过去 30 天)
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 个评论
Jan
Jan 2017-3-8
编辑:Jan 2017-3-8
@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.

请先登录,再进行评论。

采纳的回答

Jan
Jan 2017-3-8
编辑:Jan 2017-3-8
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by