Filters in pop up menu

2 views (last 30 days)
Basanagouda Kenchanagoudra
Answered: VBBV on 29 Mar 2024
I have code which reads Test.csv data into GUI into two pop up menus like below.
The code I have used is
My requirement is,
1.) Wanted to get only Bus companies in the Register pop up menu when Bus is selected Module pop up menu
Right now, all the items are coming in Register pop up menu when I select anything in Module pop up menu.
Its like adding filters in the excel file.
Can anyone help me here??
Thanks in advance

Answers (1)

VBBV
VBBV on 29 Mar 2024
Hi @Basanagouda Kenchanagoudra, You can use switch-case inside the Callback as shown below
Item = get(handles.Module_PopUp,'String') % get the unique list of items
ItemV = get(handles.Module_PopUp,'Value') % get the value of item selected in popupmenu
switch Item{ItemV} % use a swtich case for filtering items
case 'Bike'
idx = find(get_module_names == "Bike"); % search for similar items /bike
set(handles.Reg_PopUp,'String',get_reg_names(idx));
case 'Car'
idx = find(get_module_names == "Car") % search for similar items /car
set(handles.Reg_PopUp,'String',get_reg_names(idx));
case 'Bus'
idx = find(get_module_names == "Bus"); % search for similar items /bus
set(handles.Reg_PopUp,'String',get_reg_names(idx));
end

Categories

Find more on Data Import from MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!