Multiple dropdown inputs to narrow down file options in App Designer

25 ビュー (過去 30 日間)
Margaux
Margaux 2023 年 7 月 27 日
コメント済み: Jon 2023 年 7 月 27 日
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!

採用された回答

Jon
Jon 2023 年 7 月 27 日
編集済み: Jon 2023 年 7 月 27 日
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 件のコメント
Margaux
Margaux 2023 年 7 月 27 日
Ok makes sense! I'll try to implement that. Thank you!
Jon
Jon 2023 年 7 月 27 日
Good, let me know if you have more questions once you get into the details

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by