필터 지우기
필터 지우기

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 CenterFile Exchange에서 Scope 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