Retrieving data from uitable

20 vues (au cours des 30 derniers jours)
Jeremy
Jeremy le 23 Déc 2012
I am attempting to use the data from an editable uitable, but I am seeing no difference after making edits in the user interface. Here is what the code looks like:
dat=zeros(1,4);
columnformat={'numeric','numeric','numeric','numeric'};
columneditable=[true true true true];
t=uitable('Data',dat,'ColumnFormat',columnformat,'ColumnEditable',columneditable);
It is displaying my variable 'dat' as [0 0 0 0], and when I try to change it to [1 1 1 1] in the uitable (hoping to eventually be able to retrieve it as a double value, not a string), nothing happens. I click off of the table and then check the value of dat in the workspace and it still reads as [0 0 0 0].
Not sure if I should be doing something with CellEditCallback? Any ideas?
Thanks!
  3 commentaires
Jeremy
Jeremy le 23 Déc 2012
Yes, I had added a celleditcallback that outputted the value of dat, and it would run the callback and show me dat, but the values of dat did not change.
Walter Roberson
Walter Roberson le 23 Déc 2012
Could you show the callback? Also, did the callback show the updated values or the original values?

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 23 Déc 2012
Dat is not going to change until you retrieve the value from the table. It doesn't change automatically when you edit the table. And it doesn't change on a character by character basis as you type (this isn't Visual Studio after all). You need to get the values:
tableData = get(handles.uitable1, 'data');
Is that how you're retrieving the data? You need to have focus off the table (so you're not still editing it), and you might even need to call guidata() before you call get(). When exactly does your celleditcallback get executed?
  9 commentaires
Image Analyst
Image Analyst le 5 Mar 2017
If there is an error message, that will tell you why. Read this
Walter Roberson
Walter Roberson le 5 Mar 2017
If you are using R2014b or later, then potentially the java table returned will have different components.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur App Building dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by