Clear Filters
Clear Filters

What is the best way of deleting multiple rows of a uitable using a pushbutton?

1 view (last 30 days)
I am creating a to-do list where entries, dates, identification of importance are each column in a uitable. I want to delete one or more rows depending on what the user selects or identifies with a delete button that is also in the GUI.

Answers (1)

Walter Roberson
Walter Roberson on 14 Apr 2017
When you have converted the vector of checkbox values from cell to matrix, then you can logical() that to get a mask. The mask would correspond to entries to delete. For your purpose it is probably easier to use a vector of things to save:
mask = logical(MatrixCheckboxesValue);
IndexC = ~mask;
Then this next section is copied directly from that previous code:
ReorderCheckboxes = CheckboxesVValue(IndexC);
ReorderEntryEdits = EntryEditsVString(IndexC);
ReorderDueDateEdits = DueDateEditsVString(IndexC);
ReorderImportantToggles = ImportantTogglesVValue(IndexC);
but only a subset of the locations are to be changed:
num_kept = sum(IndexC);
set( DueDateEditsV(1:num_kept), {'String'}, ReorderDueDateEdits);
set( EntryEditsV(1:num_kept), {'String'}, ReorderEntryEdits);
set( CheckboxesV(1:num_kept), {'Value'}, ReorderCheckboxes);
set( ImportantTogglesV(1:num_kept), {'Value'}, ReorderImportantToggles);
After that, you have some unused entries to deal with, the ones from num_kept+1:end . You could delete them, or you could set their visible off and put them in a pool of already-created objects ready for re-use.

Categories

Find more on Migrate GUIDE Apps 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!