how to check all boxes in uitable column with a button?

15 visualizaciones (últimos 30 días)
Shalaka Kollerkandy
Shalaka Kollerkandy el 29 de En. de 2021
Respondida: dpb el 30 de En. de 2021
Hi, I want to create a button under my uitable that will check all the boxes in the uitable. currently all the check boxes are in one column so I basically want to select all the cells in this column when I click the button. My uitable data is from an excel file that is read in, if that changes anything.

Respuestas (1)

dpb
dpb el 30 de En. de 2021
Just put the code to set the column variable all to TRUE in the callback for your pushbutton...trivial example from uitable doc...
t = readtable('patients.xls');
vars = {'Age','Systolic','Diastolic','Smoker'};
t = t(1:5,vars);
hUIfig = uifigure;
uit = uitable(hUIfig,'Data',t);
uib=uibutton(hUIfig,'Text','Check All', ...
'ButtonPushedFcn', @(btn,event) fnButtonPushed(btn,uit));
has a table with one Smoker checked and a "Check All" button:
The button function would look something like:
function plotButtonPushed(btn,uit)
uit.Data.Smoker=true(height(uit.Data),1);
end
NB: This updates the data table in the GUI uitable but NOT that in the local copy of the table, t.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by