Effacer les filtres
Effacer les filtres

Troubles with writing to an editable table.

2 vues (au cours des 30 derniers jours)
Roy Veldhuizen
Roy Veldhuizen le 27 Juin 2012
Hello everybody,
I'm writing a GUI, which includes a uitable(tagged uitable) with the following headers:
  • Original Gear
  • Original Shift Distance
  • New Gear
  • New Shift Distance
I'm running my program, which calculates the two original values. I send them to the uitable function by:
matrix=[Sgear Sshift];
set(handles.uitable,'Data',matrix);
guidata(hObject,handles);
thus filling two of the four columns of the table. Subsequently, I want to be able to allow the user to enter alternative values in the other two columns. To ensure this; I've set ColumnEditable to a logical of [0 0 1 1]. However, when I try to enter the values in the two blank columns, the columns do allow entering of the values, but as soon as i move on to a next cell, it returns to blank again. The EditData in the eventdata shows the correct value,the error in the eventdata shows:'Table data is not editable at this location.'
Before running the entire code, it is possible to enter data in the 2 last columns, and data remains shown as it is supposed to be. However, after running the code, and calculating the the first two columns, this is not the case anymore.
It seems to me that inserting data from another function, blocks the possibility for manual entering of the values in some way.
I hope you guys understand the issues, and give me some tips =)
Roy

Réponse acceptée

Walter Roberson
Walter Roberson le 27 Juin 2012
Have you tried setting the data as cell a cell array instead of as a numeric matrix?
matrix = [ num2cell(Sgear), num2cell(Sshift) ];
set(handles.uitable,'Data',matrix);
If that was not sufficient, I would suggest
matrix = [ num2cell(Sgear), num2cell(Sshift), cell(size(Sgear,1),2) ];
set(handles.uitable,'Data',matrix);
to provide empty cells for the data to go into.
  4 commentaires
Roy Veldhuizen
Roy Veldhuizen le 28 Juin 2012
Hello Walter,
I've tried it with a 4 column numeric matrix, and as you suspected, it was indeed editable again. Still I find it rather strange that the values of ColumnEditable return back to their default values. This is making it difficult to alter just a part of the 'Data' field whilst leaving the rest untouched. Either way, I solved the issue, thanks again!
Walter Roberson
Walter Roberson le 28 Juin 2012
There is no MATLAB-level mechanism to set only part of a uitable. To change the table contents from a program, you set() the entire table again.
I think there are Java-level mechanisms based upon uitable's underlying implementation.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Scope Variables and Generate Names dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by