How to get indices of selected uitable cell outside cellselection callback

조회 수: 56 (최근 30일)
Kunal Singhal
Kunal Singhal 2017년 10월 31일
답변: 병주 김 2022년 5월 16일
I have a uitable in appdesigner with a struct array containing some elements from the table and some additional elements that I do not display in the table. I want to make changes to any of these elements after a press a button. I am trying to get the index/ data of the selected cell in the table which will help me locate them in the structure and then update the changes. Since there is no getselected function, how to get this index outside the cellselectioncallback without having to add additional column with check box

답변 (2개)

Mary Abbott
Mary Abbott 2017년 11월 3일
Hello,
To accomplish this, you can create a property in your app that will store the currently selected indices. Then, add a cellSelectionCallback that updates this property every time a new cell is selected. This would look something like:
% (Add selectedCell property to store indices)
% Cell selection callback: UITable
function UITableCellSelection(app, event)
app.selectedCell = event.Indices;
end
  댓글 수: 4
Maryam Abbaszadeh
Maryam Abbaszadeh 2020년 9월 14일
How to define selectedCell as a property?
Biraj Khanal
Biraj Khanal 2022년 1월 17일
Add this to the class definition:
properties (Access = private)
selectedCell
end

댓글을 달려면 로그인하십시오.


병주 김
병주 김 2022년 5월 16일
Does it work?
I also coded like that, but matlab says there is no property of field names Indices like below fig.
Do you know how could I handle this?

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by