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

4 vues (au cours des 30 derniers jours)
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 commentaires
Jan
Jan le 8 Mar 2017
Modifié(e) : Jan le 8 Mar 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 le 8 Mar 2017
Ah yes, I see now. I missed the mode line. It's a while since I've created a uitable!

Connectez-vous pour commenter.

Réponse acceptée

Jan
Jan le 8 Mar 2017
Modifié(e) : Jan le 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.

Plus de réponses (0)

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by