How to uncheck all other checkboxes when one is selected in App Designer Table
I have a UITable in App Desinger. The first column is logical and therefore displays editable checkboxes. My objective is to have all other checkboxes cleared (unchecked) after I select a single check box. My current section of code is the following:
% Callbacks that handle component events
methods (Access = private)
% Cell edit callback: UITable
function UITableCellEdit(app, event)
% If the edited column is the checkbox column
if event.Indices(2) == 1
% Uncheck other checkboxes in the column after selection
if event.NewData
app.UITable.Data(:, 1) = {false};
end
app.UITable.Data{event.Indices(1), 1} = event.NewData; % Check the clicked checkbox
end
end
end
However, when I run the app I can still have multiple checkboxes selected at a time. This is not my intended effect. Again, I only want one checkbox to be able to be selected at a time; when one is selected all others should be cleared.I have a UITable in App Desinger. The first column is logical and therefore displays editable checkboxes. My objective is to have all other checkboxes cleared (unchecked) after I select a single check box. My current section of code is the following:
% Callbacks that handle component events
methods (Access = private)
% Cell edit callback: UITable
function UITableCellEdit(app, event)
% If the edited column is the checkbox column
if event.Indices(2) == 1
% Uncheck other checkboxes in the column after selection
if event.NewData
app.UITable.Data(:, 1) = {false};
end
app.UITable.Data{event.Indices(1), 1} = event.NewData; % Check the clicked checkbox
end
end
end
However, when I run the app I can still have multiple checkboxes selected at a time. This is not my intended effect. Again, I only want one checkbox to be able to be selected at a time; when one is selected all others should be cleared. I have a UITable in App Desinger. The first column is logical and therefore displays editable checkboxes. My objective is to have all other checkboxes cleared (unchecked) after I select a single check box. My current section of code is the following:
% Callbacks that handle component events
methods (Access = private)
% Cell edit callback: UITable
function UITableCellEdit(app, event)
% If the edited column is the checkbox column
if event.Indices(2) == 1
% Uncheck other checkboxes in the column after selection
if event.NewData
app.UITable.Data(:, 1) = {false};
end
app.UITable.Data{event.Indices(1), 1} = event.NewData; % Check the clicked checkbox
end
end
end
However, when I run the app I can still have multiple checkboxes selected at a time. This is not my intended effect. Again, I only want one checkbox to be able to be selected at a time; when one is selected all others should be cleared. checkbox, uitable MATLAB Answers — New Questions