valuelist with global method.

Questions, tips and tricks and techniques for scripting in Servoy

valuelist with global method.

Postby rmidata » Tue Feb 16, 2010 4:34 pm

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.
Roberto Diez.
Interdata Software.
Santa Fe, Argentina.
User avatar
rmidata
 
Posts: 42
Joined: Thu Jul 09, 2009 10:26 pm
Location: Santa Fe, Argentina.

Re: valuelist with global method.

Postby jcompagner » Tue Feb 16, 2010 6:09 pm

if you attach that method to a valuelist
Then servoy will call that method for you when it needs to fill the valuelist.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: valuelist with global method.

Postby rmidata » Tue Feb 16, 2010 11:32 pm

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.
Roberto Diez.
Interdata Software.
Santa Fe, Argentina.
User avatar
rmidata
 
Posts: 42
Joined: Thu Jul 09, 2009 10:26 pm
Location: Santa Fe, Argentina.

Re: valuelist with global method.

Postby jcompagner » Wed Feb 17, 2010 10:26 am

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)
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: valuelist with global method.

Postby rmidata » Wed Feb 17, 2010 4:47 pm

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.
Roberto Diez.
Interdata Software.
Santa Fe, Argentina.
User avatar
rmidata
 
Posts: 42
Joined: Thu Jul 09, 2009 10:26 pm
Location: Santa Fe, Argentina.

Re: valuelist with global method.

Postby jcompagner » Thu Feb 18, 2010 10:19 am

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.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: valuelist with global method.

Postby nromeou » Wed Jan 25, 2012 9:01 pm

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
nromeou
 
Posts: 215
Joined: Fri Sep 18, 2009 8:38 pm
Location: Montevideo, Uruguay

Re: valuelist with global method.

Postby lwjwillemsen » Thu Jan 26, 2012 12:10 am

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,
Lambert Willemsen
Vision Development BV
lwjwillemsen
 
Posts: 680
Joined: Sat Mar 14, 2009 5:39 pm
Location: The Netherlands

Re: valuelist with global method.

Postby Hans Nieuwenhuis » Thu Jan 26, 2012 10:58 am

A request has been made for this :

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

Regards,
Hans Nieuwenhuis
Betagraphics
http://www.deltics.nl
http://www.betagraphics.nl

Servoy Version 7.3.1
Java version 1.7.0.x
Database Oracle 11g
User avatar
Hans Nieuwenhuis
 
Posts: 1026
Joined: Thu Apr 12, 2007 12:36 pm
Location: Hengelo, The Netherlands

Re: valuelist with global method.

Postby nromeou » Thu Jan 26, 2012 3:55 pm

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.
nromeou
 
Posts: 215
Joined: Fri Sep 18, 2009 8:38 pm
Location: Montevideo, Uruguay

Re: valuelist with global method.

Postby lwjwillemsen » Thu Jan 26, 2012 5:24 pm

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,
Lambert Willemsen
Vision Development BV
lwjwillemsen
 
Posts: 680
Joined: Sat Mar 14, 2009 5:39 pm
Location: The Netherlands

Re: valuelist with global method.

Postby nromeou » Thu Jan 26, 2012 7:37 pm

Hi,

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

Regards
nromeou
 
Posts: 215
Joined: Fri Sep 18, 2009 8:38 pm
Location: Montevideo, Uruguay

Re: valuelist with global method.

Postby jcompagner » Fri Jan 27, 2012 12:07 pm

i would say: vote for it
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet


Return to Methods

Who is online

Users browsing this forum: No registered users and 8 guests