App Designer User edit/update table

32 ビュー (過去 30 日間)
ted yao
ted yao 2019 年 12 月 23 日
コメント済み: Kojiro Saito 2021 年 7 月 7 日
Hello,
I am new to app designer so forgive me for asking silly questions:
I have loaded an cell array data from excel into my app design table:
and I would like to know how can a user update the value in cell?
I have created a call back function below that It's supposed to responde to user commond whenever the table is clicked
function CBICDispCellEdit(app, event)
indices = event.Indices;
newData = event.NewData;
app.table.ColumnEditable=[false,false,false,false,false,false,true];
app.table.Cmd=categorical({'open';'close'});
But nothing happened when I clicked on the table...
Is there anything I am missing here? Thanks

採用された回答

Kojiro Saito
Kojiro Saito 2019 年 12 月 24 日
編集済み: Kojiro Saito 2020 年 1 月 6 日
CellEditCallback is triggered when the value of cell has changed. If you want to trigger an event when clicking the cell of table, you need to add callback of CellSelectionCallback.
Updated on 2020 Jan 6th.
In order to make drop down list in your Cmd column of the table, first you need to change import options of your excel file.
function LoadTableButtonPushed(app, event)
opts = detectImportOptions('test1.xlsx'); % For importing Cmd column as char not double
opts.VariableTypes{8} = 'string'; % For importing Cmd column as string
t = readtable('test1.xlsx', opts);
app.Table1.Data = t;
app.Table1.ColumnName = t.Properties.VariableNames;
end
And here is a code to make Cmd column as categorical.
function Table1CellSelection(app, event)
app.UITable.Data.Cmd = categorical(app.UITable.Data.Cmd, {'open', 'close'});
end
Screenshot is as the follows.
202016144726.jpg
  2 件のコメント
ted yao
ted yao 2020 年 1 月 2 日
Thanks,
I have changed it to cellselection but I am still having trobule to get the code to wok.
Let me attach my code and excel file,
After loading the file I am trying to change the value in column 'cmd'. (Using a drop down list, categorical data with 'open' or 'close' selection)
Could you please show me how to do this? Thank you.
Regards,
Ted
Kojiro Saito
Kojiro Saito 2020 年 1 月 6 日
@Ted
I've updated my previous answer.

サインインしてコメントする。

その他の回答 (1 件)

John K. George
John K. George 2021 年 7 月 6 日
Hi Kojiro,
I'm trying to implement your solution after reading an excel file. Please see attached. I have taken a slightly different approach due to my contraints but I'm hoping I can still use your implementation - w/modification. thx.
John
  2 件のコメント
John K. George
John K. George 2021 年 7 月 6 日
What am I missing? The dropdowns are still not working when I run from AppDesigner. I can only highlight the column values - no dropdowns.
Kojiro Saito
Kojiro Saito 2021 年 7 月 7 日
Could you post your question in a new thread, please?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeTime Series Objects についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by