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

2 vues (au cours des 30 derniers jours)
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

Réponse acceptée

joe
joe le 13 Fév 2018
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')

Plus de réponses (0)

Catégories

En savoir plus sur Logical 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