Hi there
I try to set the value of a function into a global variable.
Every way I try didn’t work.
I just wann call this function once in my script to put the value of the grid into a global variable to use it in the hole script.
There is just one value in the grid, and I wanna set the value of 0 or 1 into a global variable auth.
Sorry, but that didn’t works for me because I need the value into a variable, neather in a alert nor with a button assigned.
When the alert is in the function it works (var auth has value of the grid cell), but outside of the function the value of the variable auth is “undefined”.
I wanna call this function once at the very beginning of the code and store the value into a value where I can use in the hole script.
Please, make sure that the needed cell is already loaded to the grid.
If issue still occurs for you - please, provide us with a sample of your code so we can reproduce the issue and provide you a proper solution.
Attached I send you the code I use.
The PHP script gives back the remote calling IP in a “pseudo” (but valid!) grid cell.
If you use the example code, the first alert works fine with IP 127.0.0.1, but the second alert gives back “undefined”…
For me it looks like the value of auth ist correct in the function where the grid cell ist processed, but outside the value of auth ist undefined.
Thanks a lot for your help !!!
Best wishes
Franky
DHTMLX-Code:
AuthHiddenGrid = new dhtmlXGridObject(‘dummy’);
AuthHiddenGrid.setHeader("");
AuthHiddenGrid.init();
var auth = AuthHiddenGrid.loadXML(“scripts/check_user.php”,function(){
auth = AuthHiddenGrid.cells(1,0).getValue();
alert(“1 [”+auth+"]"); // <------- Right before the return the value of auth ist 127.0.0.1
return auth;
})
alert(“2 [”+auth+"]"); // <------- Here I wanna have the value of the grid cell, but is undefined
Unfortunately at that it’s not available to find the value at that moment as the data is not loaded to the grid yet. Please, try to call it from a callback function of the load() method or in onXLE event. docs.dhtmlx.com/doku.php?id=dhtm … vent_onxle
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan