Effacer les filtres
Effacer les filtres

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

14 vues (au cours des 30 derniers jours)
Shalaka Kollerkandy
Shalaka Kollerkandy le 29 Jan 2021
Réponse apportée : dpb le 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.

Réponses (1)

dpb
dpb le 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.

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by