valuelist with global method.

Hi.
How to use the global method of a ValueList.
I have it written, but as I run it and pass it parameters.
Someone could help me with an example.

My global method is:

function getDataSetForValueList(displayValue, realValue, record, valueListName) {
if (displayValue == null && realValue == null) {
return databaseManager.getDataSetByQuery(“Interdata”, “select adn_nombre, adn_id from adn”, null, 100);
} else if (displayValue != null) {
var args = [displayValue + “%”, displayValue + “%”]
return databaseManager.getDataSetByQuery(“Interdata”, “select adn_nombre, adn_id from adn where adn_nombre like ? or adn_apellido like ?”, args, 100);
} else if (realValue != null) {
var args = [realValue];
return databaseManager.getDataSetByQuery(“Interdata”, “select adn_nombre, adn_id from adn where adn_id = ?”, args, 1);
}
}

How they run and where?
Thank
Roberto Diez.
Interdata.
Rep.Argentina.

if you attach that method to a valuelist
Then servoy will call that method for you when it needs to fill the valuelist.

Thanks Johan.
If I attach the method to ValueList working properly, but I can not pass the arguments to the method.
Now the question is how and when you pass the method arguments.
Thanks again.
Roberto Diez.
Interdata.
Argentina.

we pass the arguments for you: displayValue, realValue, record, valueListName
you cant pass any other, thats just the arguments the valuelist global method gets. (and not everything has to be set for a specific call, see the sample code)

Thanks again Johan!
What you explained is correct and works very well.
The problem is as follows:
I want to define a single method and to allocate it to various ValueList, therefore, as you call the method with different parameters values.
When I attach the method to ValueList in the developer, you can not change the values of the parameters, therefore, as I do?
I hope to be clear on what I’m asking.
Thank you.
Roberto Diez.
Interdata.
Argentina.

no the parameters you get are static, they are what i told above.

If you attach that method to various valuelist then the last parameter is the valuelist name so you know which one did the call.

So which parameters you get are predefined and the values of those are generated by servoy when it happens.

Hi,
I found out this post looking for ways to use the getDataSetForValueList and you were very helpful, so thought I could ask you about a problem I have with this.
I’m using getDataSetForValueList to load a valuelist, the problem is I need to activate this everytime someone sets some other parameter.
The list should be reloaded with the new filtered values, problem is it is not being reloaded.
When debuggin, returned data is correct, but it seems as if Servoy doesn’t care for the changes, it is still showing the old valuelist items.

Should I post a bug issue or is this flexibility not supported??
Do you know some workaround for this?

Thanks for your help

Hi,

I stated earlier in this forum that a globalMethodvaluelist.rePopulate() would be very nice to have…
Too bad it isn’t there.

Ugly workaround :
oldValue = dataprovider value
dataprovider value = -1
dataprovider value = oldValue

This triggers a repopulation of the valuelist.

I assume you use just like us global variables in your getDataSetForValueList() for context info.

Regards,

A request has been made for this :

https://support.servoy.com/browse/SVY-1376

Regards,

Hi,

Lambert, I do… too bad this is not fixed yet.
One thing though, am I suposed to call my getDataSetForValueList each time I change the dataprovider value??
For example:

oldValue = dataprovider value
dataprovider value = -1
getDataSetForValueList
dataprovider value = oldValue
getDataSetForValueList

Thanks for your help

BTW, thanks for making that request Hans.

Hi Nromeou,

One thing though, am I suposed to call my getDataSetForValueList each time I change the dataprovider value??

No, you are not. Servoy does that for you automatically when the realValue of the dataprovider changes to a value that is not contained in the current valuelist.
Setting the realValue to null does not have that effect.

@Hans : Thanks for making the feature request.

We find the globalMethodValuelist very very powerful…

Regards,

Hi,

Thanks for the help, it worked perfectly.
Please keep us posted on the request, can’t wait to see that one…

Regards

i would say: vote for it