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 Import and Export 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
