Got the following error: table data is not editable at this location

Hi all,
I have a uitable. When I run the code and try and set a value to the table I get the error above and when I look at the evendata structure values I see:
  1. Indices is correct
  2. Prev' Data is [] which is correct
  3. Edit Data holds the new data I chose (is correct)
  4. New Data is [] -> WHY?? why isn't it equal to Edit Data?
  5. Error = "table data is not editable at this location"
What am I missing? I have cells as editable.
Here is the uitable code (I shorted it a bit for the unnecessary parts)
ColumnFormat = {{' ' 'STA1' 'STA2' 'STA3' 'STA4'},...
{' ' 'Voice' 'Video' 'Best Effort' 'Background'},...
'numeric',...
'numeric',...
'numeric',...
'numeric',...
'numeric',...
{' ' 'Poason' 'Syncronious'},...
{' ' 'TCP' 'UDP' 'G711'},...
{' ' 'None' 'WEP' 'TKIP'},...
'numeric'};
ColumnEditable = [true true true true true true true true true true false];
handles.STADataTable(STANumber) = uitable(...
'Parent',handles.STAPanel(STANumber),...
'units','pixels',...
'ColumnWidth','auto',...
'ColumnFormat',ColumnFormat,...
'ColumnEditable',ColumnEditable,...
'CellEditCallback',{@STADataTable_Callback,handles},...
'Position',[48 5 1039 19*3+2]);

6 Comments

Were you trying to edit column 11 ? You have it marked false for editable.
No - Column 11 is not editable.
I tried several other cells...
Additional to the above that I have noticed:
After I built the table, I checked its 'Data' and its = [ ].
Is it possible that I need to set the data to be as the size of the table (i.e. 1x11)? (and make them as ' ' and not [ ])?
I set up a table in GUIDE mode and the table cell values were ' '...
OK, it seems to be the problem but I do not know what is the right and best solution. here is the code I added after making the table that solves the problem:
TableColumnSize = size(get(handles.STADataTable(STANumber),'ColumnName'));
TempRow = cellfun(@(x) '',cell(1,TableColumnSize(1)),'uniformoutput',false);
set(handles.STADataTable(STANumber),'Data',TempRow);
Now when I enter a value to the table - I do not get an error.
I kinda understand the problem but what is the BEST way to write this? (Don't think my solution is best, no?)
repmat({''}, 1, TableColumnSize(1))
would be one way. Or
TempRow = cell(1,TableColumnSize(1)); TempRow(:) = {''};
1st - Thanks.
2nd - But is this needed when I make a uitable?
Do I need to define the data cells before I let the user set value to it?

Sign in to comment.

Answers (0)

Asked:

on 6 Mar 2013

Community Treasure Hunt

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

Start Hunting!