フィルターのクリア

Troubles with writing to an editable table.

2 ビュー (過去 30 日間)
Roy Veldhuizen
Roy Veldhuizen 2012 年 6 月 27 日
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

採用された回答

Walter Roberson
Walter Roberson 2012 年 6 月 27 日
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 件のコメント
Roy Veldhuizen
Roy Veldhuizen 2012 年 6 月 28 日
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 2012 年 6 月 28 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeScope Variables and Generate Names についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by