Popup menu in uitable - There is no String property on the Table class.

1 view (last 30 days)
I have this code and when I want to switch cases with the following code
listliterature={'Kim and Feng (2003) - Longitudinal', 'Kim and Feng (2003) - Transverse',...
'Sextos,Koilanitis and Moschonas (2011) - Bilinear' ,'Sextos,Koilanitis and Moschonas (2011)- Trilinear'...
'Guo A. et al.(2014)- After 100 years','Guo A. et al. (2014) - After 90 years','Guo A. et al. (2014) - After 80 years'...
'Guo A. et al. (2014) - After 70 years','Guo A. et al. (2014) - After 60 years','Guo A. et al. (2014) - After 30 years'...
'Guo A. et al. (2014) - Sound', 'Neilson G.(2015) - Rix - MSC Concrete'};
popup_column2 = 2;
col_fmt = get(handles.uitable1, 'ColumnFormat');
col_fmt{popup_column2} = listliterature
set(handles.uitable1, 'ColumnFormat', col_fmt);
str = get(hObject, 'String');
switch str
case 1... etc
I have this error:
Error using matlab.ui.control.Table/get
There is no String property on the Table class.
Error in main5>uitable1_CellEditCallback (line 206)
str = get(hObject, 'String')
How can I solve this problem? Thank you in advance

Accepted Answer

Walter Roberson
Walter Roberson on 20 Sep 2015
You need to set the column to be editable.
To retrieve you need to get the Data property of the table, index that at the appropriate cell, and look at the value there.
  3 Comments
Steven Lord
Steven Lord on 21 Sep 2015
I think you might have missed the most important part of Walter's suggestion. UITABLE objects do not have a String property; they have a Data property that contains the table data.
If your data is stored in the Data property as a numeric array, your cases should also be numeric. If your data is stored as a cell array containing strings, your cases should be strings. You can actually include both in the same case or include them in separate cases, as appropriate:
for k = {1, '1', 2, '2'}
x = k{1}; % First x will be the number 1, then the string '1', etc.
switch x
case {1, '1'}
disp('X is a 1');
case {2}
disp('X is the number 2');
otherwise
disp('X is the string ''2''');
end
end

Sign in to comment.

More Answers (0)

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!