checkbox in table unclickable

조회 수: 9 (최근 30일)
William Gaillard
William Gaillard 2019년 3월 6일
답변: Konstantin Patroev 2020년 11월 26일
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
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
William Gaillard
William Gaillard 2019년 7월 11일
Hey Colin,
I have not fixed this problem. I may try the answer by Vili just to see if I can improve on it, but I don't think it will get me where I want to be.

댓글을 달려면 로그인하십시오.

답변 (2개)

Vili Keränen
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.

Konstantin Patroev
Konstantin Patroev 2020년 11월 26일
You can manually set this in the App designer intereface, at the bottom right:
Then you set your columns to editable as so:

카테고리

Help CenterFile 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!

Translated by