checkbox in table unclickable
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a table generated in Matlab App Designer. The 1st column in the table has check boxes. All other columns are numeric. I have a pushbutton called delete. I want any row that is checked to be deleted from the table when the delete button is clicked on. I don't see anyway to initialize the table format within the App Designer Design View. To set the column format, I have the following startup function in the Code View:
% Code that executes after component creation
function startupFcn(app)
set(app.UITable, 'ColumnFormat', {'logical', 'numeric', 'numeric'});
set(app.UITable,'ColumnEditable',logical([1 1 1]));
end
Data is entered into the table via pushbuttons and edit fields or by clicking a cell and entering a value. In Design View I have all columns set to editable (which does not seem to do anything as far as I can tell). Without the second line in the code above I cannot edit any cell in the table (I would think this code is redundent given that I have all columns set to editable in Design View, but this is not the case). With the second line of code the numberic cells work as expected; however, the checkboxes are not clickable. Any idea why?
When I click a check box I get the following warning:
Warning: Cannot convert logical edit to numeric matrix.
Please click for more information
When I click the link I get the following error
Error using helpUtils.csh.helpviewMLFactory/checkForMapFile (line
27)
Specified map file does not exist:
C:\Program Files\MATLAB\R2018a\help\techdoc\ref\hg.uitable.map
Error in helpview (line 215)
help_path = factory.checkForMapFile(mapfilename, topic_id);
2 commentaires
Colin Krebbers
le 20 Juin 2019
Hi William,
Were you able to fix the problem regarding the checkboxes?
I'm facing the exact same issue while reusing your code.
Kind regards,
Colin
Réponses (2)
Vili Keränen
le 10 Juil 2019
Hey guys,
I'm experiencing the same issue. You probably figured this out already, but you can work around the issue with CellEdit callback.
% Cell edit callback: UITable
function UITableCellEdit(app, event)
indices = event.Indices;
if app.UITable.Data(indices(1),indices(2)) == true % In this example column containing checkboxes
app.UITable.Data(indices(1),indices(2)) = false % is the only editable column.
else
app.UITable.Data(indices(1),indices(2)) = true
end
end
Doesn't remove the error, but atleast checkboxes now change state.
0 commentaires
Konstantin Patroev
le 26 Nov 2020
You can manually set this in the App designer intereface, at the bottom right:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/429758/image.png)
Then you set your columns to editable as so:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/429763/image.png)
0 commentaires
Voir également
Catégories
En savoir plus sur Function Creation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!