question

Laura Vasquez avatar image
2 Likes"
Laura Vasquez asked Matthew Gillespie edited

how to link a listbox to a dashboard button?

FlexSim 7.7.4
dashboardsmodel input
· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Sam Stubbs avatar image Sam Stubbs ♦ commented ·

I'm not sure I understand what you mean by "link" a button to the listbox. What functionality are you looking for?

0 Likes 0 ·
Laura Vasquez avatar image Laura Vasquez commented ·

Yes, I want to press the buttom in the dashboard and then get some info display in the listbox

0 Likes 0 ·

1 Answer

·
Matthew Gillespie avatar image
1 Like"
Matthew Gillespie answered Matthew Gillespie edited

First, you need to set an ID on the listbox for easy reference. Click on the listbox and you'll see the ID field in Quick Properties. For the next steps I'm going to assume you entered myListBox as the ID.

Second, you'll need to add some custom code to the On Press trigger of your button. Click on your button and find the On Press trigger field. Click the properties button and choose Code Snippet from the list (or just open the code editor). Enter your code, here is some example code that will populate the listbox with the list of objects in your model:

treenode list = getdashboardcontrol("myListBox");
clearcontents(items(list));

for(int i = 2; i <= content(model()); i++) {
	treenode listItem = nodeinsertinto(items(list));
	setname(listItem, getname(rank(model(), i)));
}

listboxrefresh(list);

We're using getdashboardcontrol("myListBox") to get a reference to your listbox. The contents displayed by the listbox are represented by nodes on the listbox's items node. So first we clear the contents of that node. Then we loop through all the objects in the model and add a new subnode to the listbox's items node and give it the name of the object it's representing. Finally, to refresh the listbox and show the new values we call listboxrefresh on the listbox.

Third, you'll need to clear the Edit Mode check box in quick properties either for the whole dashboard or just for the button.

· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Laura Vasquez avatar image Laura Vasquez commented ·

Hi Matthew!, thanks for your fast reply!.

It is my first time that I´m using the "model inputs" in the dashboard and I´m little lost!

I wonder if you could help me a little bit with the syntax of the code, I want to develop the following template for the managers of the company I work for; shown in the picture down.

The template will be a visual help for the user; where the user has to choose the date of the initiation, turn (3 possible options) and select the operator for each station depend on the turn; the table will show the plan of the day work and the bottom down will calculate

How long will the order be completed with selected operators.

-the user will first select the "time" in the combobox----Do you know how to link the

the combobox "time" to the table "plan of the day" from other table where the info will be display.

-Then, the user will choose one of the three possible turns- Do you know how to link the listbox "turn" to each of the listbox "subassembly stations" or "personalitation stations" to show different operator of each turn based also from other tables with the information of each turn.

I hope you had time to reply and give me a clearer idea of how to get started.

Regards!

0 Likes 0 ·
capture.png (18.1 KiB)
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Laura Vasquez commented ·
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.