Harjo
November 27, 2012, 3:58pm
1
HI,
I have some method where I scan all the elements of a form and get the dataproviderID of an element.
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?
Joas
November 28, 2012, 1:02pm
2
Try something like:
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.
Harjo
November 28, 2012, 1:14pm
3
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?
Joas
November 28, 2012, 2:17pm
4
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:
var split = vProviderID.split(".");
if (/^globals\./test(vProviderID)) {
globals[split[1]] = null;
} else if (/^scopes\./.test(vProviderID)) {
scopes[split[1]][split[2]] = null;
}
Harjo
November 28, 2012, 4:19pm
5
No, but i thought there was maybe another way to set a (global) dataprovider independant of the name.
this should work:
eval(vProviderID + '=null;')
or if you have a form
vForm.controller.setDataProviderValue(vProviderID, null)
Joas
November 28, 2012, 4:45pm
7
Harjo:
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.
Harjo
November 28, 2012, 7:59pm
8
jbrancoIF:
this should work:
eval(vProviderID + '=null;')
or if you have a form
vForm.controller.setDataProviderValue(vProviderID, null)
YES jBrancoIF, you are the man!
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!