Page 1 of 1

valuelist with global method.

PostPosted: Tue Feb 16, 2010 4:34 pm
by rmidata
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.

Re: valuelist with global method.

PostPosted: Tue Feb 16, 2010 6:09 pm
by jcompagner
if you attach that method to a valuelist
Then servoy will call that method for you when it needs to fill the valuelist.

Re: valuelist with global method.

PostPosted: Tue Feb 16, 2010 11:32 pm
by rmidata
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.

Re: valuelist with global method.

PostPosted: Wed Feb 17, 2010 10:26 am
by jcompagner
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)

Re: valuelist with global method.

PostPosted: Wed Feb 17, 2010 4:47 pm
by rmidata
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.

Re: valuelist with global method.

PostPosted: Thu Feb 18, 2010 10:19 am
by jcompagner
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.

Re: valuelist with global method.

PostPosted: Wed Jan 25, 2012 9:01 pm
by nromeou
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

Re: valuelist with global method.

PostPosted: Thu Jan 26, 2012 12:10 am
by lwjwillemsen
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,

Re: valuelist with global method.

PostPosted: Thu Jan 26, 2012 10:58 am
by Hans Nieuwenhuis
A request has been made for this :

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

Regards,

Re: valuelist with global method.

PostPosted: Thu Jan 26, 2012 3:55 pm
by nromeou
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:
Code: Select all
oldValue = dataprovider value
dataprovider value = -1
getDataSetForValueList
dataprovider value = oldValue
getDataSetForValueList


Thanks for your help

BTW, thanks for making that request Hans.

Re: valuelist with global method.

PostPosted: Thu Jan 26, 2012 5:24 pm
by lwjwillemsen
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,

Re: valuelist with global method.

PostPosted: Thu Jan 26, 2012 7:37 pm
by nromeou
Hi,

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

Regards

Re: valuelist with global method.

PostPosted: Fri Jan 27, 2012 12:07 pm
by jcompagner
i would say: vote for it