Page 1 of 2
getObj and Subfile Grid
Posted: Fri Mar 09, 2012 1:58 pm
by rmullis
I am trying to get the value of a field in a subfile grid in a script but keep getting the following error:
Onclick Error:
Unable to get value of the property 'value':object is null or undefined
This is my script in the onclick event:
var openfile = "RUNDLL32 SHELL32.DLL,ShellExec_RunDLL " + getObj("FULLFILE").value;runPCCommand(openfile);
I have double and tripled checked to make sure the my field is called FULLFILE. What is the correct syntax for retrieving a grid field in a script?
Re: getObj and Subfile Grid
Posted: Fri Mar 09, 2012 3:03 pm
by Brian
You are almost there. fields in a grid need a row number to identify them. So you are looking for something like FULLFILE.3 where 3 is the grid row. Profound UI provides a special variable called "row" to get the current row number. Also, instead of using getObj, there is another api included to retrieve the value of an element. The API is get(). So try it like this:
Code: Select all
var openfile = "RUNDLL32 SHELL32.DLL,ShellExec_RunDLL " + get("FULLFILE." + row); runPCCommand(openfile);
Re: getObj and Subfile Grid
Posted: Fri Mar 09, 2012 3:09 pm
by rmullis
Brian,
I get a different error now. It says that 'row' is not defined.
Re: getObj and Subfile Grid
Posted: Fri Mar 09, 2012 5:07 pm
by rmullis
Brian,
FYI, the script is in the onclick event on a hyperlink in a column in the grid.
Re: getObj and Subfile Grid
Posted: Mon Mar 12, 2012 9:26 am
by Brian
Ok, I was thinking you were using the onrowclick event. So the row variable is not available in your situation, but we can retrieve the row number by looking at the element name of the widget being clicked. This should get you going.
Code: Select all
var id = this.id;
row=id.split(".")[1];
var openfile = "RUNDLL32 SHELL32.DLL,ShellExec_RunDLL " + get("FULLFILE." + row);
runPCCommand(openfile);
What this code does is get the element name of the current widget and then set row equal to the portion of the element id after the period (which is the row number).
Let me know if you still have issues.
Re: getObj and Subfile Grid
Posted: Mon Mar 12, 2012 11:08 am
by rmullis
Brian,
I don't have the issue of row being undefined. Now when I click on the hyperlink, nothing happens.
One other thing (but I can't see why it would make a difference), field FULLFILE is a hidden field in the subfile.
Is it possible that the var id = this.id is retrieving the id of the hyperlink and not the subfile grid?
Re: getObj and Subfile Grid
Posted: Mon Mar 12, 2012 3:14 pm
by Brian
Are you sure you are running loadPCCommandApplet() beforehand?
Re: getObj and Subfile Grid
Posted: Mon Mar 12, 2012 3:23 pm
by rmullis
Yes, I am running the loadPCCommandApplet in the onload event in the screen.
I can "hardcode" the name of the file in the IFS in my script and it loads, but when I try to retrieve it from the grid row, nothing happens. I have double and triple checked my RPG program to make sure the field FULLFILE has the correct format, etc.
Re: getObj and Subfile Grid
Posted: Mon Mar 12, 2012 3:43 pm
by Brian
hmm. Have you looked at it using firebug or chrome's developer tools? You should be able to look at the call in one of those to see if maybe the formatting is different that you are expecting.
Re: getObj and Subfile Grid
Posted: Mon Mar 12, 2012 3:48 pm
by rmullis
I wouldn't even know how to begin doing that. You are talking to an old green-screen programmer.