dynamic add menuitem to menubar in VL WEB

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
kno_dk
Posts: 89
Joined: Tue Feb 23, 2016 12:00 am

dynamic add menuitem to menubar in VL WEB

Post by kno_dk » Fri Feb 22, 2019 1:39 am

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

Pablo
Posts: 43
Joined: Wed Dec 02, 2015 10:35 am

Re: dynamic add menuitem to menubar in VL WEB

Post by Pablo » Fri Feb 22, 2019 2:53 am

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)

kno_dk
Posts: 89
Joined: Tue Feb 23, 2016 12:00 am

Re: dynamic add menuitem to menubar in VL WEB

Post by kno_dk » Fri Feb 22, 2019 9:00 pm

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

Pablo
Posts: 43
Joined: Wed Dec 02, 2015 10:35 am

Re: dynamic add menuitem to menubar in VL WEB

Post by Pablo » Fri Feb 22, 2019 10:24 pm

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

Post Reply