My uitable cells do not hold text input?
Show older comments
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 Comments
Walter Roberson
on 29 Feb 2024
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
on 29 Feb 2024
Voss
on 29 Feb 2024
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
on 29 Feb 2024
Alex
on 29 Feb 2024
Accepted Answer
More Answers (0)
Categories
Find more on Data Type Identification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!