How to get indices of selected uitable cell outside cellselection callback

34 Ansichten (letzte 30 Tage)
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

Antworten (2)

Mary Abbott
Mary Abbott am 3 Nov. 2017
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 Kommentare
Biraj Khanal
Biraj Khanal am 17 Jan. 2022
Add this to the class definition:
properties (Access = private)
selectedCell
end

Melden Sie sich an, um zu kommentieren.


병주 김
병주 김 am 16 Mai 2022
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?

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by