UITable dropdown option in column not working

12 ビュー (過去 30 日間)
L1n022
L1n022 2020 年 4 月 9 日
編集済み: L1n022 2020 年 4 月 9 日
I am trying to create a dropdown option in the third column of my table. If I use the documentation data (variable Data) with my dropdown choices, it works. If I try using my data (variable myData), it does not work. I have also tried the categorical replacement for the specific column in the table and that did not work for me. Thanks for your insight.
% Generate Data
material_list = {'material1','material2','material3'};
num = [1 2 3]';
type = {'A', 'B', 'C'}';
% Generate "Choose" for last column
choose = repmat({'Choose'},length(num),1);
% Build table
my_table = table(num,type,choose);
myData = table2cell(my_table);
fig = uifigure;
% Matlab documentation data
Data = {'Andrew' 31 'Male' 'Choose'; ...
'Bob' 41 'Male' 'Choose'; ...
'Anne' 20 'Female' 'Choose';};
% Build uitable
uit = uitable('Parent', fig, ...
'Position', [100 150 380 100], ...
'ColumnFormat',({[] [] [] material_list}), ...
'ColumnEditable',true, ...
'Data',myData); % myData does not work, % Data works.

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 4 月 9 日
Change the value to the property 'ColumnFormat'
% Build uitable
uit = uitable('Parent', fig, ...
'Position', [100 150 380 100], ...
'ColumnFormat',({[] [] material_list}), ... % number of elements should be same as number of columns
'ColumnEditable',true, ...
'Data',myData); % myData does not work, % Data works.
  2 件のコメント
L1n022
L1n022 2020 年 4 月 9 日
編集済み: L1n022 2020 年 4 月 9 日
Well...that's embarrassing. Thank you for your help Ameer.
Ameer Hamza
Ameer Hamza 2020 年 4 月 9 日
No problem. Glad to be of help.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop 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