Problem with data of uitable

조회 수: 5 (최근 30일)
Andres Beltran
Andres Beltran 2015년 7월 7일
댓글: Andres Beltran 2015년 7월 7일
Hello I am working in a interface where a button displays a figure which contains a table with some data, I created the table with this code
t = uitable('Position',[20 50 260 100],'Data', d,...
'ColumnName', columnname,...
'ColumnFormat', columnformat,...
'ColumnEditable', [false true true],...
'RowName',[],'CellEditCallBack',@editTable_Callback,'Tag','Tabla1','HandleVisibility','Callback');
But when I try to retrieve the data as
get(handles.Tabla1,'Data')
it shows me an error
Reference to non-existent field 'Tabla1'.
Also if I look at handles it does not appear the handles of the table I created
I appreciate your assistance

채택된 답변

Joseph Cheng
Joseph Cheng 2015년 7월 7일
편집: Joseph Cheng 2015년 7월 7일
since you're coding the uitable instead of using GUIDE you do not have the handles structure. you already have the handles for the uitable assigned to t.
so you just need to go get(t,'data').
the tag works differently when not using GUIDE as it is not also the same name as the GUI item. since you manually assign it to t you should know what item you're referring to. the tag is useful if you need to search for it but right now i cannot get a good instance when you need to. but to find the handles of the uitable if you do not have it you can find it by using the line findall(0,'tag','Tabla1')
  댓글 수: 1
Andres Beltran
Andres Beltran 2015년 7월 7일
Thanks Joseph I do not know if you can help me with another issue. if I try to change a value on the table i want to update the data in the position of t (Table) and save that information to use later in another function
function editTable_Callback(hObject,callbackdata,handles)
% hObject handle to pb (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
r = callbackdata.Indices(1);
c = callbackdata.Indices(2);
if c==3
d=struct2cell(callbackdata);
dato=d(4,1);
else
dato=eval(callbackdata.EditData);
end
hObject.Data{r,c} = dato
This function is supposed to change the data in the position and the if is because c that is the column in the third position is a popupmenu and I use this to convert to a char and the others I storage them as doubles but what I saw is that t value is not updating.
I appreciate your help
Thanks
Andres Felipe Beltran

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by