Multiple editable tables in app designer

8 views (last 30 days)
Irina Ion
Irina Ion on 20 Oct 2019
Answered: Katie on 23 Oct 2019
Greetings, I'm using multiple editable tables in MATLAB's app designer and as soon as I try to edit the second one, all the values in the first table are reinitialized to 0.
Also, if I want to move on to insert other values in the second table, it does not hold the previous value either.
Any ideas?

Accepted Answer

Katie on 23 Oct 2019
Hi! I've made a couple apps with multiple editable tables, and here's how I've done it.
Disclaimer: my tables tend to be pretty small so I'm not really concerned with doing operations the most efficient way. I'm also typically pulling values out of my tables to use in calculations and then writing calculation results to other tables or plotting them. These two things drive my approach, but for your specific application there could be other drivers.
  • Initialize the tables in the startup function
  • Create a celledit callback for each table. In the callback, I just put the updateTable_(app) function for the respective table.
function Table1CellEdit(app,event)
  • Create a private update table function for each table. I either store the values in the table in properties (option 1) because I use them to do other calculations throughout the app or write property values to the table (option 2) because I've calculated a quantitity and I want to display it in the table.
function updateTable1(app)
%pick either option 1 approach or option 2 approach
%option 1:
%option 2:
%write data to the table
  • I'm not 100% sure what you mean by insert values into your second table. If you mean add rows to your table here's what I do: To insert values into my tables, I have a button to add a table row. When the row is added, it is initialized with a set of values, then I use the appropriate updateTable_(app) function for the table to store all the values into properties again. After that, I can edit the fields in the new row of the table or the previous rows without anything happening to the other rows/cells. If by insert values into the second table you mean edit the cells, having the celledit callback function for the table with the updateTable_(app) function should take care of holding previous values.
%callback function for button push
function AddRowButtonPushed(app,event)
newData={0,0,0};%initialize new row
app.Table1.Data=[T;newData];%put the new data with the old data into the table
Hope this helps! If not, if you could provide some more details and/or some code, I could try to recreate your isssue and work it further.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by