フィルターのクリア

checkbox in table unclickable

27 ビュー (過去 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 Center および File ExchangeFunction Creation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by