uitable create modify and save

4 次查看(过去 30 天)
Hello,
I have a 2D table and I would like to display this table and select some of lines of this table. I think the best is to create another column in my table set at 0 and when I want to select some line, I modify 0 to 1. After, I want to close the window (with a button) and retrieve the table (modified) in my Matlab workspace.
For that I choose to create an uitable. But I did not find how to :
  • Create another column to select the lines I want.
  • Create a uitable I can close with a button
  • Retrieve the table with the last column.
Thanks,
Pierre
  1 个评论
Mohammad Sami
Mohammad Sami 2020-1-21
Just add an extra column to your data, then set as the Data property of the uitable.
After you are done with the updates, retreive the Data property to see what was selected.
% change yourdata to your variable name . type is table
yourdata.lastcol = false(height(yourdata),1);
f = uifigure('CloseRequestFcn',@(varargin)uiresume(gcbf));
editcols = false(1,width(yourdata));
editcols(end) = true;
t = uitable(f,'Data',yourdata,'ColumnEditable',editcols);
uiwait(f); % this will block until the figure is closed.
updatedata = t.Data;
close(f);
delete(f);

请先登录,再进行评论。

回答(1 个)

Payas Bahade
Payas Bahade 2020-1-24
Hi Pierre-François,
I have created a demo App in App Designer which can be used to retrieve selected lines from given table. Refer to the .mlapp file in attachment.
Instead of making use of ‘0’ or ‘1’, I have used a separate checkbox column to select the rows whose data needs to be retrieved in a variable ‘newTable’ in MATALB workspace.
Hope this helps!
  1 个评论
Pierre-François Bourdelle
Hello Payas,
Thanks for you code, it's really helpful.
Apparently you created a class with App Designer...
Now, after some calculations, I have the table I want to show. But how to integrate your class in my existing code?
Thanks
Pierre-François

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by