MATLAB GUI developers often want to have a mini-spreadsheet in their GUI. This can be done with a new widget added to the set of controls available in GUIDE. Now with UITABLE you can add that capability. This video shows how to add a table for display, then makes it editable and adds a callback such that MATLAB code is run whenever a cell in the table is edited. The data is not linked to the variables in the workspace, so this callback shows you how to pull data out of the table whenever it is updated.
Doug, nice post. One thing, though: it occurs to me that you haven’t shown us how to use/share the value of the variable DATA (from the data in the table) outside of the workspace of the cellEditCallback workspace. There are several ways to do it–addressing the ways, and their relative merits, would make a nice follow-up blog!
UITable was undocumented, but available, for some releases in the past.
Some features like this are available, but undocumented, for various reasons. Sometimes they are there so that we can use them in making tools for MATLAB. These features are undocumented because we need the flexibility to change the interface for a while. If you find undocumented features, you need to be aware that the interface can change or be removed in future releases.
As far as access is concerned, the undocumented uitable of old provided cut and paste options from a uicontextmenu but the new version does not. Is that something that will be addressed in future releases?
I have a gui with a uitable that works well when you hit enter after each cell edit, but when you hit tab after editing a cell’s contents, the CellEditCallback is not executed. Is there a fix for this?
My question follows the previous post here. I am trying to edit the cells of a table. It works well if I hit tab after entering data. However, if I choose the contents of a cell by mouse-click-and-drag, and edit it, unless I click in another cell, the CellEditCallback is not called. I tend to edit the last cell, and then directly press a button that processes the data. So, I end up missing the data on the last cell I edit. How can I rectify this?
By the way, I am sincerely grateful for the most educative and helpful posts. I even considered developing GUI, solely due to your videos.
Hi, I have Matlab 7.5.0 (R2007b) and I need to create a table on an interface, but in the GUI doesn’t exist a botton to create it, do I have to install something to obtain that botton in my GUI
I created uitable in my GUI app by Guide, and set some properies by Table Property Editor, to be exact, for Columns set
[numeric numeric numeric CHOICE_LIST logical numeric]
1 2 3 4 5 6
And I would like to input my data to table. Beforehand I created my data as cell (4×6), where {i,4} is cell array of strings for corresponding 4th column (pop-up menu)
K>> handles.visualdata.params
ans =
Columns 1 through 5
[ 20] [10] [ 300] {1×29 cell} [0]
[ 5] [ 5] [ 50] {1×10 cell} [1]
[ 2] [ 1] [ 10] {1×9 cell} [1]
[733788] [ 1] [733796] {1×7 cell} [0]
Column 6
[ 20]
[ 5]
[ 2]
[733788]
K>> set(handles.uitable_params,’Data’,handles.visualdata.params);
??? Error using ==> set
Values within a cell array must be numeric, logical, or char
——————–
Doug, could you tell me if I have posibility to set different popup menu for each row?
So are these tables only numeric, or can we use a mixed type cell array to populate them?
Also I am currently using 7.5 and see that these tables are available but undocumented. It seems like in this version the ‘data’ is a java object.
Doug, nice post. One thing, though: it occurs to me that you haven’t shown us how to use/share the value of the variable DATA (from the data in the table) outside of the workspace of the cellEditCallback workspace. There are several ways to do it–addressing the ways, and their relative merits, would make a nice follow-up blog!
Brett, I agree. Given that the uitable is a new addition to MATLAB it would be great to see more discussion about various access methods.
Harold,
UITable was undocumented, but available, for some releases in the past.
Some features like this are available, but undocumented, for various reasons. Sometimes they are there so that we can use them in making tools for MATLAB. These features are undocumented because we need the flexibility to change the interface for a while. If you find undocumented features, you need to be aware that the interface can change or be removed in future releases.
-Doug
As far as access is concerned, the undocumented uitable of old provided cut and paste options from a uicontextmenu but the new version does not. Is that something that will be addressed in future releases?
Malcolm,
This suggestion has been entered into our internal enhancement request database. Thanks for the suggestion.
Doug
Hello Doug,
I have a gui with a uitable that works well when you hit enter after each cell edit, but when you hit tab after editing a cell’s contents, the CellEditCallback is not executed. Is there a fix for this?
Thanks,
Austin DeHart
Austin,
This is a known issue. I see that it has been fixed in the next release.
Doug
Hey Doug,
My question follows the previous post here. I am trying to edit the cells of a table. It works well if I hit tab after entering data. However, if I choose the contents of a cell by mouse-click-and-drag, and edit it, unless I click in another cell, the CellEditCallback is not called. I tend to edit the last cell, and then directly press a button that processes the data. So, I end up missing the data on the last cell I edit. How can I rectify this?
By the way, I am sincerely grateful for the most educative and helpful posts. I even considered developing GUI, solely due to your videos.
Thank you very much,
Keerthi
Keerthi,
Our developers are aware of that behavior. A change in behavior is likely in an upcoming release.
Doug
Hi, I have Matlab 7.5.0 (R2007b) and I need to create a table on an interface, but in the GUI doesn’t exist a botton to create it, do I have to install something to obtain that botton in my GUI
Thanks.
Hector,
This was a new feature of 2008a. You will need to upgrade to get the functionality.
Doug
Hi, Doug!
I created uitable in my GUI app by Guide, and set some properies by Table Property Editor, to be exact, for Columns set
[numeric numeric numeric CHOICE_LIST logical numeric]
1 2 3 4 5 6
And I would like to input my data to table. Beforehand I created my data as cell (4×6), where {i,4} is cell array of strings for corresponding 4th column (pop-up menu)
K>> handles.visualdata.params
ans =
Columns 1 through 5
[ 20] [10] [ 300] {1×29 cell} [0]
[ 5] [ 5] [ 50] {1×10 cell} [1]
[ 2] [ 1] [ 10] {1×9 cell} [1]
[733788] [ 1] [733796] {1×7 cell} [0]
Column 6
[ 20]
[ 5]
[ 2]
[733788]
K>> set(handles.uitable_params,’Data’,handles.visualdata.params);
??? Error using ==> set
Values within a cell array must be numeric, logical, or char
——————–
Doug, could you tell me if I have posibility to set different popup menu for each row?
Yana,
Each column will have one set of choices for the choice menu. You can not vary it by row.
-Doug