My uitable cells do not hold text input?
이전 댓글 표시
I have a uitable object in an app. The first column of the table is not editable -- I cannot click or type anything in it. The second column should be editable with free text input. I can click and type letters(ex. "blahblasdfh"), but when I press "enter" or click away, it just reverts to its default value (ex. a simple dash "-").
I control the format of the columns of this table, and suspect this may be the root of the problem. The column I need to be able to edit has format 'char' currently. As I understand it, there is no way to format a table column for strings input, but it is functionally the same as a 'char' vector for me.
Why doesn't the table hold my text once I press enter? Any tips?
function refreshColumnFormat(app)
tag = get(app.SequenceTable, 'ColumnName');
actuation_type = app.TagTable.Data(:,3);
formatArray = cell([1,length(tag)]);
for i = 1:(length(tag))
if i<=2
formatArray{i} = {'char'};
else
if ismember(actuation_type(i-2),'OPEN/CLOSE')
formatArray{i} = {'OPEN', 'CLOSE'};
elseif ismember (actuation_type(i-2), 'ON/OFF')
formatArray{i} = {'ON', 'OFF'};
elseif ismember(actuation_type(i-2), 'RUN/STOP')
formatArray{i} = {'RUN', 'STOP'};
end
end
end
app.SequenceTable.ColumnFormat = formatArray;
end
댓글 수: 7
Walter Roberson
2024년 2월 29일
actuation_type = app.TagTable.Data(:,3);
What datatype is that? You index it with (i-2) but expect the result to work in an ismember() . You would need it to be string() datatype for that to work.
Alex
2024년 2월 29일
Voss
2024년 2월 29일
I'm unable to reproduce the problem. I would check everywhere in your code that sets the uitable's Data and make sure it's doing it right. If you can't find the culprit, then upload your app (and any necessary data) so people can try to run it for themselves.
Alex
2024년 2월 29일
Alex
2024년 2월 29일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Type Identification에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
