checkbox in table unclickable
11 次查看(过去 30 天)
显示 更早的评论
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 个评论
Colin Krebbers
2019-6-20
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
回答(2 个)
Vili Keränen
2019-7-10
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 个评论
Konstantin Patroev
2020-11-26
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!