Multiple dropdown inputs to narrow down file options in App Designer
24 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Good morning!
I have been using MATLAB App Designer for two months or so and right now, I am having some troubles using drop downs.
My goal is to have the user choosing 3 different values in 3 different drop downs. By choosing the first value in the first drop down, depending on the available options in the database, the values will adapt in the second drop down and then the user will pick a second value. After the first two values are chosen, the values in the third drop down will adjust again so that the user can choose the value needed. Once the three values are chosen, a different drop down menu otside of this panel will display the files that matches the values chosen by the user so that its data can be uploaded and the data plotted.
Would it be something possible?
Thank you!
1 comentario
Respuesta aceptada
Jon
el 27 de Jul. de 2023
Editada: Jon
el 27 de Jul. de 2023
I have attached a very simple example of how you might have the choice from one drop down menu change the possible choices from a second drop down. In this example initially both drop downs have three items. The first has Choice A, Choice B, Choice C, the second has Choice 1, Choice 2, Choice 3. When you select an item from the first list, the corresponding element is eliminated from the second list. So if you pick Choice B from the first list, the second drop down becomes Choice 1, Choice 3 (Choice 2 is eliminated). Anyhow this is just to illustrate the principle. You can modify with your specific logic.
The key idea is to use the value changed callback from the first drop down, to modify the Items property of the second,
% Code that executes after component creation
function startupFcn(app)
% Define initial drop down item lists
app.DropDown1.Items = {'Choice A','Choice B','Choice C'};
app.DropDown2.Items = {'Choice 1','Choice 2','Choice 3'};
end
% Value changed function: DropDown1
function DropDown1ValueChanged(app, event)
value = app.DropDown1.Value;
% Modify second drop down menu according to choice made here,
% specifically eliminate corresponding drop down item in the
% second list
idx = find(ismember(app.DropDown1.Items,value));
app.DropDown2.Items(idx) = [];
end
4 comentarios
Jon
el 27 de Jul. de 2023
Good, let me know if you have more questions once you get into the details
Más respuestas (0)
Ver también
Categorías
Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!