I have a subfile and in each row I have two separate hyperlinks that when pressed, I'd like to execute the URL contained in that hyperlink.
Each hyperlink would contain data(parms or whatnot) unique to that row in the grid.
The other thing I'd like is to have the column that is displayed for each of the hyperlinks NOT be the actual URL that I want to execute (I'd like it to be a name or something more user friendly).
From the RPG, I'd like to pre-fill all necessary information so that when they click on the subfile/grid, it does NOT have to return to the iseries to gather any additional information, but rather can immediately execute the "url"(hyperlink) that was clicked on.
I may be over complicating things, but I don't see an easy way to accomplish this (though I may very well be missing something). can you point me to an example that may be similar to what I'm describing (if it's possible)?
Thanks!
Here's the code I tried in the "onclick" of one of the hyperlink fields:
var GR2 = getObj("Grid2"); pui.link("Mailto1." + GR2.row + ".value");
The Mailto1 is another hidden hyperlink that contains the "link" I want to execute (in this case a simple mailto). I've tried a few different things, but basically, I was attempting to retrieve the row that was clicked (the hyperlink field was actually clicked) and then execute the Mailto1 from that row.
Subfile/Grid and client side execution
-
- Profound User
- Posts: 83
- Joined: Sun Oct 03, 2010 8:45 am
- First Name: Mike
- Last Name: Geldert
- Company Name: Stonriver
- Country: Angola
- Contact:
-
- Profound User
- Posts: 27
- Joined: Thu Dec 02, 2010 1:27 pm
- First Name: Greg
- Last Name: Sears
- Company Name: Profound Logic
- Phone: 937-439-7925
- Address 1: 562 Congress Park
- City: Dayton
- State / Province: Ohio
- Zip / Postal Code: 45459
- Country: United States
- Contact:
Re: Subfile/Grid and client side execution
This is definitely possible; however, the JavaScript code will look a little different.
You will not have access to the row variable in the onclick event of the hyperlink. The row is only available in the onrowclick event of the grid. However, you can determine the row by looking at the id of the element that was clicked. A reference to the element that is clicked on can be obtained using JavaScript’s “this” keyword.
You will need two subfile elements: a hyperlink, which the user will click, and another element that will contain the destination link. The destination link element can be hidden. You should assign the destination link an id, such as “link”.
The code that you would in the hyperlink’s onclick event would look like this:
var nameId = this.id;
var row = nameId.split(".")[1];
var linkId = "link." + row;
var url = get(linkId);
window.open(url);
The code can go directly into the onclick event, or you can create an external function in a JavaScript file, and just call that function from the onclick.
If the url is a mailto link, replace the window.open() with pui.link(). However, if it is a standard url, leave it as window.open().
You will not have access to the row variable in the onclick event of the hyperlink. The row is only available in the onrowclick event of the grid. However, you can determine the row by looking at the id of the element that was clicked. A reference to the element that is clicked on can be obtained using JavaScript’s “this” keyword.
You will need two subfile elements: a hyperlink, which the user will click, and another element that will contain the destination link. The destination link element can be hidden. You should assign the destination link an id, such as “link”.
The code that you would in the hyperlink’s onclick event would look like this:
var nameId = this.id;
var row = nameId.split(".")[1];
var linkId = "link." + row;
var url = get(linkId);
window.open(url);
The code can go directly into the onclick event, or you can create an external function in a JavaScript file, and just call that function from the onclick.
If the url is a mailto link, replace the window.open() with pui.link(). However, if it is a standard url, leave it as window.open().
-
- Profound User
- Posts: 83
- Joined: Sun Oct 03, 2010 8:45 am
- First Name: Mike
- Last Name: Geldert
- Company Name: Stonriver
- Country: Angola
- Contact:
Re: Subfile/Grid and client side execution
FANTASTIC!
Thanks again
Thanks again
Who is online
Users browsing this forum: No registered users and 3 guests