How do I add a Table in App Designer?

With due respect, the instructions for App Designer are at best counter-intuitive and hermetic. For example, how to create a Table with 3 columns and 3 rows (besides the row of column headings), name columns AND rows, and populate the cells with Default values. Make these cell data entries editable by the user when running the app. The app sould take these Table data (and other data from the Slider, Knob, etc.), run a code that generates a plot.
I am stuck in trying to add Row Names. The User Community advises I need to add Table data first. But there seems to be no place in Design View to add such data!

11 Comments

There are LOTS of options with UI tables. But once you take the time to go through all of them, you'll realize it's fairly managable.
Here are all the properties you can manipulate with uitables:
And here are some examples of editing uitables in app designer
Thanks, but the basic question still remains: while building a new app using the App Designer, how to address and use all these wonderful properties of Tables from Design View (or Code View)?
Incidentally, this example, copied verbatim from your 2nd link does not work! See attached screen shot.
Uitable_error.jpg
Categorical inputs work in 2018a but I confirmed that they don't work in 2017b (your version). Anyway, there's lots of examples out there that use numeric, logical, or cell array variables.
Thanks. That example now works (after swtiching to R2018b). But my original question still remains unanswered. When building a new app using the app designer, how does the user build a table (esp. row names) from Design view (or code view)? As is, a table is a no go witout data and the above views don't seem to allow data input. This is unlike other app elements like the slider.
Here's another set of examples of tables built in App.
If you're adding the table within the app instead of prgrammatically, you can set the parameters from within the app. But you can also set the parameters within the code. The examples in the link above mention the propery "ColumnEditable" which enables/disables the user's ability to edit the table (allow input). This was also covered in one of the links I provided in an earlier comment that lists all properties of tables.
Thanks again. But this example merely shows a page in the documentation. It would be more instructive to let the learner bring up the actual app in question (blood pressure monitoring?) and see how the interactive Table is implemented.
As for my original question, it still remains unanswered. (I did read the PDF manual on Apps.) When building an app from scratch, simple components (slider, knob, drop down, etc.) are self-contained by way of explanation. Not so with Tables. Drag a Table into the app window. The user can edit the column names. Then the music stops. There's no (clear) indication of how to proceed with populating the Table, naming the rows, and so on. Perhaps such can be done only programmatically.
May I recommend a course on "Interplanetary communication" before a scientist or engineer attempts to develop an app? It may help with interpreting Matlab's "instructions" for app designer!
I agree the documentation could be better in that sense.
  1. From the App Designer in design mode, right click anywhere on your app background, hover your mouse over 'callbacks', and add a startupFcn callback.
  2. Go to Code View and you'll see the startupFcn. Add your data to your table there. You can refer to the documentation I shared which will be helpful now that you know how to add the table data.
app.UITable.Data = {1 2 3 4};
Thanks. By coincidence, I tried the satrtupFCN approach before your suggestion! It works, but just one glitch remains. The Table appears in a new window (instead of the main window where the other items, like sliders are normally dragged into). Getting there! Thanks again for your attention.
If you share that snippet of code I might be able to help. Also, I'll move the response to the 'answers' section so others may find it useful in the future.
Here is a tutorial on adding rows and columns to tables in app designer:

Sign in to comment.

 Accepted Answer

Adam Danz
Adam Danz on 20 Nov 2018
Edited: Adam Danz on 20 Nov 2018
To add data to a UItable in App Designer, use the startupFcn() after creating the table in the UI.
  1. From the App Designer in design mode, right click anywhere on your app background, hover your mouse over 'callbacks', and add a startupFcn callback.
  2. Go to Code View and you'll see the startupFcn. Add your data to your table there. Refer to the documentation below to change other properties of the table.
app.UITable.Data = {1 2 3 4};

5 Comments

Uhhh. Wow. Greaaate answer.
i don't see startupFcn callback..i do something wrong?
I read your link but couldn't find it
In the link, see the image in the first step. You must select your app in the component browser.

Sign in to comment.

More Answers (2)

Paul Macey
Paul Macey on 17 Jun 2020
Edited: Paul Macey on 17 Jun 2020
Should really have a way to initalize in properties with at least one empty row.....
Here's what I did in the app startupFcn
app.ColorsUITable.Data = cell(1,length(app.ColorsUITable.ColumnName));

1 Comment

That is the way to initialize a table with 1 empty row.
For some data types you can use <missing>

Sign in to comment.

You can edit the RowName, ColumnName and ColumnEditable Properties of a UITable from the Property Inspector of App Designer.
You cannot add Data to a UITable from the Design View of App Designer, you will need to add the data in a StartupFcn (or other callback). For example
function startupFcn(app)
app.UITable.Data = rand(2,4);
end
Will result in:

2 Comments

what if i want to add a value in Column 1 row Two only?
app.UITable.Data(2,1) = value;

Sign in to comment.

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Asked:

on 16 Nov 2018

Commented:

on 9 May 2023

Community Treasure Hunt

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

Start Hunting!