Troubles with writing to an editable table.
조회 수: 2 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
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
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 Exchange에서 Matrix Indexing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!