question

Manuel Sinco avatar image
0 Likes"
Manuel Sinco asked Manuel Sinco commented

Change Combobox options with code

Hello, I want to change the values inside the combobox using code in a dashboard GUI.

Currently I was able to change the values in the table, from the active view; however, when the Edit Mode is off and I change the values, they won't update. Here is an example of my code:

treenode combo = gui.subnodes["GraphPanel"].subnodes["Combobox_StaPath"].first;
treenode items_ = combo.find(">items");
items_.subnodes.clear();
items_.subnodes.assert("value_01",1);
items_.subnodes.assert("value_02",2);
items_.subnodes.assert("value_05",5);

the gui treenode was already defined and matches to the dashboard that is already the GUI.

So the table for the combobox is this one:

However it doesn't update and appears like this:

It will update until I turn on the Edit Mode and click in the table to this:

However I want it to update automatically due to that this will change every time I update some values.

I already updated the table in the background, the only missing step is to update the view of the table in the GUI dashboard.

I would appreciate your help.

Thank you,

Manuel.

FlexSim 19.1.2
flexsim 19.1.2
1618330132637.png (1.6 KiB)
1618330175995.png (1.6 KiB)
1618330579170.png (2.1 KiB)
5 |100000

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

1 Answer

·
Julio R avatar image
0 Likes"
Julio R answered Manuel Sinco commented

Hello @Manuel Sinco,

Can you send us your model to try a few things? If it has information that cannot be shared and you can delete everything but that dashboard that would be enough.

· 3
5 |100000

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

Manuel Sinco avatar image Manuel Sinco commented ·

Hi @Julio R I'm attaching you the model.

Update_Combobox.fsm

0 Likes 0 ·
update-combobox.fsm (17.6 KiB)
Julio R avatar image Julio R Manuel Sinco commented ·

Hello Manuel,

if at the end of your code you insert this line:

comborefresh(ownerobject(items_));

it will refresh the options.

I did not know that command, but since it changes when you select the pickoption I figure it must be one in that option, so I explored its extructure. To do this I right click the box and selected View>Explore structure,

In the tree that this shows I look for a trigger "OnPress", but it ended up being "addOption", there, I read the code and found out that command.

0 Likes 0 ·
1618358535259.png (17.8 KiB)
1618358657729.png (46.8 KiB)
Manuel Sinco avatar image Manuel Sinco Julio R commented ·

Thank you @Julio R this solved the problem, actually that's how I found how to update the values inside the table, but didn't saw that command before. Thank you!

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.