# popup menu based on a valuelist

**URL:** <https://forum.servoy.com/t/popup-menu-based-on-a-valuelist/8250>\
**Category:** Classic Servoy\
**Created:** [October 16, 2007, 10:07am UTC](https://forum.servoy.com/t/popup-menu-based-on-a-valuelist/8250 "2007-10-16T10:07:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lovedatsound](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Lovedatsound](https://forum.servoy.com/u/Lovedatsound)\
**Post date:** [October 16, 2007, 10:07am UTC](https://forum.servoy.com/t/popup-menu-based-on-a-valuelist/8250/1 "2007-10-16T10:07:42Z")

</div>

I’m trying to create a method that shows a valuelist when I click on a button. (I do not want a combobox type of valuelist, just a button that shows a menu containing the values from a certain valuelist). Up till my method is:

```auto
var vdataset = application.getValueListItems('find')
var menu = new Array()
for (var i = 1 ; i <= vdataset.getMaxRowIndex() ; i++ )
	{
	menu[i-1] = plugins.popupmenu.createMenuItem((vdataset.getvalue*i, 1), myMethod),
	menu[i-1].setMethodArguments (i+ 'arg1','arg2');
	}

```

but when I attach the method to a button and click on it, nothing happens. Does anybody know what I do wrong?

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [October 16, 2007, 10:18am UTC](https://forum.servoy.com/t/popup-menu-based-on-a-valuelist/8250/2 "2007-10-16T10:18:12Z")

</div>

```auto
var vdataset = application.getValueListItems('find')
var menu = new Array()
for (var i = 1 ; i <= vdataset.getMaxRowIndex() ; i++ )
	{
	menu[i-1] = plugins.popupmenu.createMenuItem((vdataset.getvalue*i, 1), myMethod),
	menu[i-1].setMethodArguments (i+ 'arg1','arg2');
	}

```

Looks like your issue is in vdataset.getvalue\*i, 1).

- should be (  
And getvalue() is not a known function of a dataset, getValue() is (caps sensitive).  
Also you end that line with a comma instead of a semi-colon.

So your code should look like this

```auto
var vdataset = application.getValueListItems('find')
var menu = new Array()
for (var i = 1 ; i <= vdataset.getMaxRowIndex() ; i++ )
	{
	menu[i-1] = plugins.popupmenu.createMenuItem((vdataset.getValue(i, 1), myMethod);
	menu[i-1].setMethodArguments (i+ 'arg1','arg2');
	}

```

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Lovedatsound](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Lovedatsound](https://forum.servoy.com/u/Lovedatsound)\
**Post date:** [October 16, 2007, 10:41am UTC](https://forum.servoy.com/t/popup-menu-based-on-a-valuelist/8250/3 "2007-10-16T10:41:24Z")

</div>

Wow, that was really very stupid of me.  
However, I tried the method with your advise and it still won’t show up. It now reads:

```auto
var vdataset = application.getValueListItems('find')
var menu = new Array()
for (var i = 1 ; i <= vdataset.getMaxRowIndex() ; i++ )
   {
   menu[i-1] = plugins.popupmenu.createMenuItem(vdataset.getValue(i, 1), myMethod);
   menu[i-1].setMethodArguments (i+ 'arg1','arg2');
   }

```

When I put on the debugger, it says:

> menu [com.servoy.extensions.plugins.popupmenu.swing.ScriptableJMenuItem[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=apple.laf.AquaMenuBorder@b4b8ed,  
> flags=264,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=0,left=0,  
> bottom=0,right=0],paintBorder=true,paintFocus=false,pressedIcon=,rolloverEnabled=false,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=]]

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [October 16, 2007, 10:50am UTC](https://forum.servoy.com/t/popup-menu-based-on-a-valuelist/8250/4 "2007-10-16T10:50:59Z")

</div>

Ah yes, you do need to actually show the menu.  
Make sure your button has a name property set.

Add the following to your method:

```auto
var elem = elements[application.getMethodTriggerElementName()]
if (elem != null)
{
	plugins.popupmenu.showPopupMenu(elem, menu);
	//or you can set the coordinates : plugins.popupmenu.showPopupMenu(10, 10, menu);
}

```

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Lovedatsound](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Lovedatsound](https://forum.servoy.com/u/Lovedatsound)\
**Post date:** [October 16, 2007, 11:16am UTC](https://forum.servoy.com/t/popup-menu-based-on-a-valuelist/8250/5 "2007-10-16T11:16:46Z")

</div>

Thank you so much!

> ROCLASI:  
> Ah yes, you do need to actually show the menu.  
> Make sure your button has a name property set.
> 
> Add the following to your method:
> 
> ```auto
> var elem = elements[application.getMethodTriggerElementName()]
> 
> ```

if (elem != null)  
{  
plugins.popupmenu.showPopupMenu(elem, menu);  
//or you can set the coordinates : plugins.popupmenu.showPopupMenu(10, 10, menu);  
}

> ```auto
> 
> Hope this helps.
> ```
