Hi Guys,
Sorry if this is a dumb question, but I have just now started playing with the plugins.popupmenu functions, and have run into a problem. Looking around the forums on how to use this function I came across the following :
http://forum.servoy.com/viewtopic.php?t … popup+menu
If I use the first bit of code, it works and I get a popup, but if I use the second bit of code I get an error that setMethodArguments() is not a function. I even tried David Workman’s code from servoy magazine, and got the same error.
Can someone straighten me out on what I’m not seeing? I’ve looked up and down to find that function, and can’t seem to locate it. What the heck am I doing wrong?
Thanks
Graham
Maybe you could post your code…
In general, a typical error is that people don’t realize that setMethodArguments takes an array as argument, not just a single argument. This allows you to pass several arguments.
So it should look like
var menuItem = plugins.popupmenu.createMenuItem( "menuText", method);
var menuArgs = new Array();
menuArgs[0] = 1; // if you want to pass a 1 as argument
menuItem.setMethodArguments(menuArgs);
This will pass an Array to the method “method”. So in “method” you should do:
var menuArgs = arguments[0]; // here you get the Array
var requestedId = menuArgs[0]; / Here you get the 1 assigned to menuArgs[0]
Hope this helps.
Hi Patrick,
Thanks for the answer. You guys have helped me understand servoy in a very short time. If I can’t figure out what I’m doing wrong, I’ll certainly post the code.
Thanks again
Graham
Hi All
I managed with the help of old forum discussions and Servoy Magazine to use the popupmenu plugin as desired ![Smile :-)]()
… with one exception .-)
I can’t separate the 2 columns code and name, e. g. B Biologie with a tab, i. e. the \t in the following line of code
menu = plugins.popupmenu.createMenuItem((code + “\t” + name*), setSubjectSectionCode);*
… so the 2 column popup menu display would be nicely aligned.
This is my code:
> Code:
> var query =
> " SELECT code, name" +
> " FROM subject_sections" +
> " ORDER BY code";
>
> var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), query, null, 1000);
>
> var code = dataset.getColumnAsArray(1);
> var name = dataset.getColumnAsArray(2);
>
> var menu = new Array();
>
> // Build popup menu and set method (setSubjectSectionCode) arguments
> for (var i = 1 ; i <= dataset.getMaxRowIndex() ; i++)
> {
> menu = plugins.popupmenu.createMenuItem((code + “\t” + name*), setSubjectSectionCode);*
> menu_.setMethodArguments(code*); // arguments[0] for method setSubjectSectionCode is code*
> }
> var elem = elements[application.getMethodTriggerElementName()]
> if (elem != null)
> {
> * plugins.popupmenu.showPopupMenu(elem, menu);
> }[/quote]
> I would like to display code and name in the popup, e. g. the popup content should look like:
> B Biologie
> C Chemie
> CL Chemie-Labor
> Versch. Verschiedenes
> …
> Has anybody a hint why \t does not work in the popupmenu plugin or what I am doing wrong?
> Regards, Robert
> > gmountain:
> > Hi Guys,
> > Sorry if this is a dumb question, but I have just now started playing with the plugins.popupmenu functions, and have run into a problem. Looking around the forums on how to use this function I came across the following :
> >
> > http://forum.servoy.com/viewtopic.php?t … popup+menu
> >
> > If I use the first bit of code, it works and I get a popup, but if I use the second bit of code I get an error that setMethodArguments() is not a function. I even tried David Workman’s code from servoy magazine, and got the same error.
> >
> > Can someone straighten me out on what I’m not seeing? I’ve looked up and down to find that function, and can’t seem to locate it. What the heck am I doing wrong?
> >
> > Thanks*
> > Graham_
Hi Robert,
Have you tried using HTML ? I know that works in regular valuelists (combobox, etc). Should also work in the popupmenu I think.
Hope this helps.
Hi Robert
Hmmm, I don’t get it. How would I do that to just include a HTML tab to my popupmenu line?
Thanks for help, Robert
ROCLASI:
Hi Robert,
Have you tried using HTML ? I know that works in regular valuelists (combobox, etc). Should also work in the popupmenu I think.
Hope this helps.
Robert Huber:
Hmmm, I don’t get it. How would I do that to just include a HTML tab to my popupmenu line?
Something like this:
<html><table width="100%"><tr><td>value1</td><td>value2</td><tr></table></html>