Filter löschen
Filter löschen

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

14 Ansichten (letzte 30 Tage)
Shalaka Kollerkandy
Shalaka Kollerkandy am 29 Jan. 2021
Beantwortet: dpb am 30 Jan. 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.

Antworten (1)

dpb
dpb am 30 Jan. 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.

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by