Uitable matlab with drop down menu -
i have create uitable in matlab drop downmenu. somehow drop down menu doesn't updated switch/case
i tried substituting switch/case if else condition. drop down menu gets updated doesn't give me desired output!
to simulate please run code below
any idea or pointers ?
function [] =foouitable() f = figure('position',[100 100 400 150]); % column names , column format columnname = {'available','options','suboptions'}; columnformat = {'logical','bank',{'checkbox' 'selectsuboptions'}}; % define data d = {false 'reconstruction' 'checkbox';... false 'segmentation' 'checkbox';... false 'computertomography' 'checkbox';... false, 'ultrasound', 'checkbox';... false, 'acousticemission', 'checkbox'}; % create uitable t = uitable('data', d,... 'columnwidth', {70 120 100},... 'columnname', columnname,... 'columnformat', columnformat,... 'columneditable', [true false true],... 'rowname',[],... 'celleditcallback',@edit) set(t,'tag','config_table'); function edit(src,evt) if evt.indices(2) == 1 modifypopup( src) end end % set width , height t.position(3) = t.extent(3); t.position(4) = t.extent(4); function modifypopup(src) id_group_1 = {'a.1';'a.2';'a.3'}; id_group_2 = {'b.1';'b.2';'b.3'}; id_group_3 = {'c.1';'c.2';'c.3'}; id_group_4 = {'d.1';'d.2';'d.3'}; id_group_5 = {'e.1';'e.2';'e.3'}; id_default = {'checkbox'}; config_data = get(src,'data'); selector = config_data(1:5,1); selector = cell2mat(selector); config_format = get(src,'columnformat'); if isequal(selector(1),1) config_format{3} = id_group_1'; elseif isequal(selector(2),1) config_format{3} = id_group_2'; elseif isequal(selector(3),1) config_format{3} = id_group_3'; elseif isequal(selector(4),1) config_format{3} = id_group_4'; elseif isequal(selector(5),1) config_format{3} = id_group_5'; else config_format{3} = id_default; end set(src,'data',config_data); set(src,'columnformat',config_format); end end
thanks in advance!
thanks hint excaza. implemented id_group_1 consist of 3x3 char array in 1 of rows.
[1] 'reconstruction' [3x3 char] [0] 'segmentation' 'checkbox' [0] 'computertomography' 'checkbox' [0] 'ultrasound' 'checkbox' [0] 'acousticemission' 'checkbox'
as set(src,'data',config_data); not permit cell array. @ moment seems cannot avoid using config_format inside if/else condition!!
function modifypopup(src) id_group_1 = {true 'reconstruction'... ['a.1'; 'a.2'; 'a.3'];... false 'segmentation' 'checkbox';... false 'computertomography' 'checkbox';... false, 'ultrasound', 'checkbox';... false, 'acousticemission', 'checkbox'}; id_group_2 = {false 'reconstruction' 'checkbox';... true 'segmentation' ['b.1'; 'b.2'; 'b.3'];... false 'computertomography' 'checkbox';... false, 'ultrasound', 'checkbox';... false, 'acousticemission', 'checkbox'}; id_group_3 = {false 'reconstruction' 'checkbox';... false 'segmentation' 'checkbox';... true 'computertomography'... ['c.1'; 'c.2'; 'c.3'];... false, 'ultrasound', 'checkbox';... false, 'acousticemission', 'checkbox'}; id_group_4 = {false 'reconstruction' 'checkbox';... false 'segmentation' 'checkbox';... false 'computertomography' 'checkbox';... true, 'ultrasound',... ['d.1'; 'd.2'; 'd.3'];... false, 'acousticemission', 'checkbox'}; id_group_5 = {false 'reconstruction' 'checkbox';... false 'segmentation' 'checkbox';... false 'computertomography' 'checkbox';... false, 'ultrasound', 'checkbox';... true, 'acousticemission', ['e.1'; 'e.2'; 'e.3']}; id_default = d; config_data = get(src,'data'); selector = config_data(1:5,1); selector = cell2mat(selector); config_format = get(src,'columnformat') if isequal(selector(1),1) config_data = id_group_1; elseif isequal(selector(2),1) config_data = id_group_2; elseif isequal(selector(3),1) config_data = id_group_3; elseif isequal(selector(4),1) config_data = id_group_4; elseif isequal(selector(5),1) config_data = id_group_5; else config_data = id_default; end %set(src,'columnformat', config_format) set(src,'data',config_data); end end
Comments
Post a Comment