Page 1 of 1

dynamic add menuitem to menubar in VL WEB

Posted: Fri Feb 22, 2019 1:39 am
by kno_dk
Hi.

I would like to dynamical add menuitem to a menubar in VL WEB. I have a list of groups from a table that i would like to create as menuitems. And when clicked send the value of the group to the selection of items.

is it possible?
/kno

Re: dynamic add menuitem to menubar in VL WEB

Posted: Fri Feb 22, 2019 2:53 am
by Pablo
Hi,

Create a collection of menu items:

Define_Com Class(#Prim_acol<#Prim_Md.MenuItem>) Name(#MenuItems)

Then as you instantiate new items you add them to the collection, for example:

Define_Com Class(#Prim_Md.MenuItem) Name(#TempItem) Reference(*DYNAMIC)

#TempItem <= (*New #Prim_Md.MenuItem)

Set Com(#TempItem) Parent(#Menu) Caption("Caption Item 1") Displayposition(1) ... etc

#MenuItems.Insert Item(#TempItem)

Re: dynamic add menuitem to menubar in VL WEB

Posted: Fri Feb 22, 2019 9:00 pm
by kno_dk
Hi.

It worked - thanks.

If I want to add a dynamic click on the menu item, how do I do that?
If i want to send a variable with the menuitem so when click it sends the value with the click, how do I do that

Re: dynamic add menuitem to menubar in VL WEB

Posted: Fri Feb 22, 2019 10:24 pm
by Pablo
Hi,

You can set the ComponentTag property when you create the item:

Set Com(#TempItem) Parent(#Menu) Caption("Caption Item 1") Displayposition(1) ComponentTag("Item1")

Using the collection from my earlier reply, the way to monitor the click event is like this where the Com_Sender is a reference to the clicked menu item:

Evtroutine Handling(#MenuItems<>.Click) Com_Sender(#ClickedItem)

#sys_web.alert Caption(#ClickedItem.ComponentTag)

Endroutine