I have a field with a valuelist attached, is there a way to select multiple values from the valuelist and display them at once?
Not that I know of…
I take it that a checkbox type is not what you want here ?
Cheers
Harry
You could also use the popup menu plugin and show a popup instead of using a value list. We use that if need multi select value lists but don’t want to waste too much space on the form. Of course you need some technique to store the data, for example semikolon separated.
Hello Patrick,
thank you for the suggestion, which of course I have tried, but I have still a few problems.
-
I still can’t select multiple values
-
the plugin seems to work only with a value list that is defined in the valuelist box but I want to use a method to build my value list instead.
var dataset = new Array(forms.contacts_join.contacts_join_to_communication.com_number, forms.contacts.contacts_to_communication.com_number)
application.setValueListItems('commNumber',dataset);
this code works well, but I can’t select multiple values
var dataset = application.getValueListItems('commNumber')
var menu = new Array()
for (var i = 1 ; i <= dataset.getMaxRowIndex() ; i++ )
{
menu[i-1] = plugins.popupmenu.createMenuItem(dataset.getValue(i, 1), globals.test);
menu[i-1].setMethodArguments (i+ 'arg1','arg2');
}
//set menu method arguments and check mark
var x = 0
while (menu[x])
{
//pass arguments
menu[x].setMethodArguments(menu[x].text)
//set check mark
if (globals.g_operator == menu[x].text) {
menu[x].setSelected(true)
}
else {
menu[x].setSelected(false)
}
x++
}
var elem = elements[application.getMethodTriggerElementName()]
if (elem != null)
{
plugins.popupmenu.showPopupMenu(elem, menu);
}
Instead of createMenuItem you can create a checkbox menu item (see popup menu plugin). That way you can 1. show which values are already selected (by checking the corresponding menu item) and 2. select more than one value. The only downside is that the user has to “open” the popup menu several times if he wants to select several items.
Hello Patrick,
the plugin seems to work only on a button, but not on a field, an I still can’t put more than 1 valuen in the field
Wait, I can’t follow. You don’t put “values” in fields, but text (I guess we are talking about text?).
Imagine you have this value list:
Green
Red
Blue
Yellow
Now you could store your “values” for example like this
Green; Red
Of course, you have to make sure that your field is large enough to fit several choices that the user might make.
onAction of the field you attach a method that creates the popup menu. In the given example with “Green” and “Red” you can easily figure out the current values by doing something like
var vCurrentValues = yourField.split('; ')
This gives you an array, so vCurrentValues[0] is green. Now, when you create your popup, you test if a value of your value list is already in your array (is already chosen) and make that menu item checked.
I don’t know if that helps or what you do. I also don’t know what you mean by “it works on a button but not a field”. Maybe you explain a bit more?
Ok, I have my popup method:
var array = databaseManager.getFoundSetDataProviderAsArray(forms.contacts.contacts_to_contacts_join,'contacts_join_to_communication.com_number');
array.toString()
var array2 = forms.contacts.contacts_to_communication.com_number ;
var dataset = array.concat( array2, array)
application.setValueListItems('commNumber',dataset);
databaseManager.getFoundSetDataProviderAsArray(forms.contacts.contacts_to_contacts_join,'conjoin_rel2');
var vdataset = application.getValueListItems('commNumber')
var menu = new Array()
var frm = currentcontroller.getName()
for (var i = 1 ; i <= vdataset.getMaxRowIndex() ; i++ )
{
menu[i-1] = plugins.popupmenu.createCheckboxMenuItem(vdataset.getValue(i, 1), globals.test);
menu[i-1].setMethodArguments (i+ 'arg1','arg2');
}
//set menu method arguments and check mark
var x = 0
while (menu[x])
{
//pass arguments
menu[x].setMethodArguments(menu[x].text)
//set check mark
if (globals.g_operator == menu[x].text) {
menu[x].setSelected(true)
}
else {
menu[x].setSelected(false)
}
x++
}
var elem = forms[frm].elements[application.getMethodTriggerElementName()]
if (elem != null)
{
plugins.popupmenu.showPopupMenu(elem, menu);
}
I put this method under onAction of the field, I can’t see any valuelist.
If I put the same method under the onAction of a button, I see my value list.
I hope my explanation is less confused than before.[/quote]
Without looking at your code: is the field set to non-editable?
no, this field is editable.
The first problem was that the method should be called from the OnFocusGained property. Now the method is running on the original form.
I want the script to run from a formInDialog and here is not running. My variable elem stays undifined.
You have to make the field non editable and give it a name. Then it should work.
you are right, but it is not an option. The user has to be able to edit the field any time.
This field contains an email address and I want the user to be able to choose from existing addresses or write a new one.
What I don’t understand is that in the reference guide is written that onAction is working on editable and not editable text fields, but when I click on it it doesn’t trigger the script at all
Hi irenem,
You are misunderstanding how the onAction property triggers on text fields.
If the text field is NOT editable then the onAction triggers when you click on that field because you are not allowed into the field and it then acts in a similar way to a button.
If the field is editable then clicking on the field simply gives focus to the field in order to edit data. To trigger the onAction for that field you then have to hit the enter or carriage return key
Cheers
Harry
Hi Harry,
ok, the only solution is to append the method to a button.
Thank you for the explanation.
ciao
Irene