getObj and Subfile Grid
-
- Experienced User
- Posts: 100
- Joined: Tue Feb 21, 2012 1:24 pm
- First Name: Robert
- Last Name: Mullis
- Company Name: WRC
- State / Province: Georgia
- Country: United States
- Contact:
getObj and Subfile Grid
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?
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?
- Brian
- Profound Logic Staff Member
- Posts: 286
- Joined: Thu Apr 14, 2011 10:23 am
- First Name: Brian
- Last Name: May
- Company Name: Profound Logic Software
- Contact:
Re: getObj and Subfile Grid
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);
-
- Experienced User
- Posts: 100
- Joined: Tue Feb 21, 2012 1:24 pm
- First Name: Robert
- Last Name: Mullis
- Company Name: WRC
- State / Province: Georgia
- Country: United States
- Contact:
Re: getObj and Subfile Grid
Brian,
I get a different error now. It says that 'row' is not defined.
I get a different error now. It says that 'row' is not defined.
-
- Experienced User
- Posts: 100
- Joined: Tue Feb 21, 2012 1:24 pm
- First Name: Robert
- Last Name: Mullis
- Company Name: WRC
- State / Province: Georgia
- Country: United States
- Contact:
Re: getObj and Subfile Grid
Brian,
FYI, the script is in the onclick event on a hyperlink in a column in the grid.
FYI, the script is in the onclick event on a hyperlink in a column in the grid.
- Brian
- Profound Logic Staff Member
- Posts: 286
- Joined: Thu Apr 14, 2011 10:23 am
- First Name: Brian
- Last Name: May
- Company Name: Profound Logic Software
- Contact:
Re: getObj and Subfile Grid
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.
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.
Code: Select all
var id = this.id;
row=id.split(".")[1];
var openfile = "RUNDLL32 SHELL32.DLL,ShellExec_RunDLL " + get("FULLFILE." + row);
runPCCommand(openfile);
Let me know if you still have issues.
-
- Experienced User
- Posts: 100
- Joined: Tue Feb 21, 2012 1:24 pm
- First Name: Robert
- Last Name: Mullis
- Company Name: WRC
- State / Province: Georgia
- Country: United States
- Contact:
Re: getObj and Subfile Grid
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?
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?
- Brian
- Profound Logic Staff Member
- Posts: 286
- Joined: Thu Apr 14, 2011 10:23 am
- First Name: Brian
- Last Name: May
- Company Name: Profound Logic Software
- Contact:
Re: getObj and Subfile Grid
Are you sure you are running loadPCCommandApplet() beforehand?
-
- Experienced User
- Posts: 100
- Joined: Tue Feb 21, 2012 1:24 pm
- First Name: Robert
- Last Name: Mullis
- Company Name: WRC
- State / Province: Georgia
- Country: United States
- Contact:
Re: getObj and Subfile Grid
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.
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.
- Brian
- Profound Logic Staff Member
- Posts: 286
- Joined: Thu Apr 14, 2011 10:23 am
- First Name: Brian
- Last Name: May
- Company Name: Profound Logic Software
- Contact:
Re: getObj and Subfile Grid
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.
-
- Experienced User
- Posts: 100
- Joined: Tue Feb 21, 2012 1:24 pm
- First Name: Robert
- Last Name: Mullis
- Company Name: WRC
- State / Province: Georgia
- Country: United States
- Contact:
Re: getObj and Subfile Grid
I wouldn't even know how to begin doing that. You are talking to an old green-screen programmer.
Who is online
Users browsing this forum: No registered users and 0 guests