dataproviderID setting to null

Questions, tips and tricks and techniques for scripting in Servoy

dataproviderID setting to null

Postby Harjo » Tue Nov 27, 2012 5:58 pm

HI,

I have some method where I scan all the elements of a form and get the dataproviderID of an element.

Code: Select all
var vProviderID = forms[vForm].elements[vElem].getDataProviderID()


Now for example this code returns vProviderID as a string: "scopes.globals.filter_monthfilter"
How do I set this global now to null?
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: dataproviderID setting to null

Postby Joas » Wed Nov 28, 2012 3:02 pm

Try something like:
Code: Select all
   if (/^scopes\./.test(vProviderID)) {
      var split = vProviderID.split(".");
      scopes[split[1]][split[2]] = null;
   }

You probably need to do some more checks, but you get the idea.
Joas de Haan
Yield Software Development
Need help on your project? yieldsd.com
User avatar
Joas
Site Admin
 
Posts: 842
Joined: Mon Mar 20, 2006 4:07 pm
Location: Leusden, NL

Re: dataproviderID setting to null

Postby Harjo » Wed Nov 28, 2012 3:14 pm

yes I did something like that already, but we still have code run in Servoy 6 and Servoy 6.1
In Servoy 6 there is 'scopes.' in front, so I wanted to make this just work on both...

But you say, that is not possible?
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: dataproviderID setting to null

Postby Joas » Wed Nov 28, 2012 4:17 pm

So you want the same code to work in 6.0 and 6.1? That doesn't look like a good idea to me, but it is possible if you do something like:
Code: Select all
   var split = vProviderID.split(".");
   if (/^globals\./test(vProviderID)) {
      globals[split[1]] = null;
   } else if (/^scopes\./.test(vProviderID)) {
      scopes[split[1]][split[2]] = null;
   }
Joas de Haan
Yield Software Development
Need help on your project? yieldsd.com
User avatar
Joas
Site Admin
 
Posts: 842
Joined: Mon Mar 20, 2006 4:07 pm
Location: Leusden, NL

Re: dataproviderID setting to null

Postby Harjo » Wed Nov 28, 2012 6:19 pm

No, but i thought there was maybe another way to set a (global) dataprovider independant of the name.
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: dataproviderID setting to null

Postby jbrancoIF » Wed Nov 28, 2012 6:33 pm

this should work:
Code: Select all
eval(vProviderID + '=null;')


or if you have a form
Code: Select all
vForm.controller.setDataProviderValue(vProviderID, null)
João
InfoForm SA

Servoy 2021.03
jbrancoIF
 
Posts: 68
Joined: Tue Jan 10, 2012 11:29 am

Re: dataproviderID setting to null

Postby Joas » Wed Nov 28, 2012 6:45 pm

Harjo wrote:No, but i thought there was maybe another way to set a (global) dataprovider independant of the name.

Hmmm, I'm don't think I understand correctly what you are trying to do.
Joas de Haan
Yield Software Development
Need help on your project? yieldsd.com
User avatar
Joas
Site Admin
 
Posts: 842
Joined: Mon Mar 20, 2006 4:07 pm
Location: Leusden, NL

Re: dataproviderID setting to null

Postby Harjo » Wed Nov 28, 2012 9:59 pm

jbrancoIF wrote:this should work:
Code: Select all
eval(vProviderID + '=null;')


or if you have a form
Code: Select all
vForm.controller.setDataProviderValue(vProviderID, null)


YES jBrancoIF, you are the man!

Code: Select all
vForm.controller.setDataProviderValue(vProviderID, null)

works perfectly. and despite of the name is 'scopes.globals.myglobal' (6.1.x) or 'globals.myglobal' (6.0.x)

Thanks!
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands


Return to Methods

Who is online

Users browsing this forum: No registered users and 6 guests

cron