Hy, i'm trying to reset the uitable of my GUI but its not working, I used:
set(handles.uitable,'Data','');
It apparently clean the data, but it also doesnt allow me to edit the uitable anymore. I had also used the function "reset":
reset(handles.uitable), But it didnt work either.

 채택된 답변

Walter Roberson
Walter Roberson 2011년 12월 2일

0 개 추천

Try
set(handles.uitable, 'Data', cell(size(get(handles.uitable,'Data'))));

댓글 수: 6

Guilherne
Guilherne 2011년 12월 2일
It worked but just with numbers, now i can't use strings in the uitable.
Walter Roberson
Walter Roberson 2011년 12월 2일
newd = get(handles.uitable,'Data');
charlocs = cellfun(@ischar, newd);
newd(charlocs) = {''};
newd(~charlocs) = {[]};
set(handles.uitable, 'Data', newd);
Guilherne
Guilherne 2011년 12월 3일
thanks, it really worked.
ElizabethR
ElizabethR 2016년 6월 23일
편집: ElizabethR 2016년 6월 23일
hi Walter, i have same problem. but now it has been solved with your code. May i ask what the meaning of @ischar ? newd(charlocs) = {''}; ? newd(~charlocs) = {[]}; ? thank you
Walter Roberson
Walter Roberson 2016년 6월 23일
uitable 'data' property takes a cell array, each element of which can be a string or numeric. The cellfun(@ischar, newd) runs through each cell entry and tests to see if it is string or not, returning true if it is and false otherwise. The result, charlocs, is the same size as the cell array but is true for the places that were strings and false otherwise. This logical mask is then used to set those places that were strings to be empty strings, and the negation of the logical mask is used to set the other locations to empty arrays. In this way each local is set to the empty version of what it was before, which preserves information about whether the entry was a string or not.
ElizabethR
ElizabethR 2016년 6월 24일
hi Walter, thanks for answare my question. Thank you so much for your explanation. God Bless You ^^

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

추가 답변 (2개)

aveks Gebastyan
aveks Gebastyan 2018년 8월 12일

0 개 추천

HI Walter Roberson. thanks for answer.. I have problem same how reset uitable. but it has been solved with your answer above....I have problem again, how to reset or remove checklist on the checkbox?. because I use the checkbox for insert data to uitable. so if we reset data in uitable, the cheklist in checkbox must be lost...
thanks..

댓글 수: 5

Walter Roberson
Walter Roberson 2018년 8월 12일
If [] does not work for those, then use 0 for them. 0 means unchecked.
everything doesn't work..
set(handles.checkbox1,0);
or
set(handles.checkbox1,'0');
or
set(handles.checkbox1,[]);
Walter Roberson
Walter Roberson 2018년 8월 12일
편집: Walter Roberson 2018년 8월 12일
Are you asking about uicontrol style checkbox? If so then set their Value property to 0. set(handles.checkbox1, 'Value', 0)
I thought you were asking about uitable checkbox columns.
aveks Gebastyan
aveks Gebastyan 2018년 8월 12일
thanks for answare my question. Thank you so much for your explanation. God Bless You..it's work..
yes, my question about uicontrol checkbox.
set(handles.checkbox1, 'Value', 0)
thanks this work..

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

bekir poyraz
bekir poyraz 2019년 5월 29일

0 개 추천

set(handles.uitable, 'Data', cell(size(get(handles.uitable,'Data'))));
thank you

카테고리

도움말 센터File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

질문:

2011년 12월 2일

답변:

2019년 5월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by