Error set data of table by using eventdata.Indices inside CellSelectionCallback

2 次查看(过去 30 天)
Hallo everyone,
this Error Shows up only after using set(handles.table,'Data',data):
Index exceeds matrix dimensions.
Error in GUI1>table_CellSelectionCallback (line 3197)
row_s = eventdata.Indices(1,1);
table has two columns (students and presence ) and rows(depending on how many Student in the class. let's say 10).
what i want is: if the the teacher clicks on the name of any Student (column student), on the table (cloumn presence) should marked true.
this my code Looks like:
function table_CellSelectionCallback(hObject, eventdata, handles)
row_s = eventdata.Indices(1,1);
col_s = eventdata.Indices(1,2);
%row_s = eventdata.Indices(1); % I tried this too, it gave the same Error
%col_s = eventdata.Indices(1); % I tried this too, it gave the same Error
data=eventdata.Source.Data
data(row_s,(col_s+1))={[true]}; % or olny true witout {[]} is the same result
% data(row_s,(col_s+1))=true; % tried this too, it gave the same result (Error)
set(handles.table,'Data',data)
I appreciate any help

采纳的回答

joe
joe 2018-2-13
hi everyone,
i solved that Problem and here is how i did that.
if someone wants to click on any casket of the table and get its indices and make a changes(somewhere with a Funktion on the the same table) and set that table, he should use CellEditCallBack instead of CellSelectionCallback to avoid that Problem which is:
Index exceeds matrix dimensions.
Error in GUI1>table_CellSelectionCallback (line 3197)
row_s = eventdata.Indices(1,1);
Note: the column, which you wanna click on, should be Editable.
so you should first set the column. set(handles.table.'ColumnEditable', 'On')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by