Reading a subfile grid with filtering turn on
-
- Profound User
- Posts: 21
- Joined: Mon Dec 15, 2014 5:21 pm
- First Name: Randy
- Last Name: Heinz
- Company Name: Southwestern Motor Transport
- Phone: 210.662.3272
- Address 1: 4600 Goldfield
- City: San Antonio
- State / Province: Texas
- Zip / Postal Code: 78218
- Country: United States
- Contact:
Reading a subfile grid with filtering turn on
After loading a subfile grid with records, a user will right click on the header and filter a column. What's displayed on the page is correct (based on filter) and I can export the grid data to excel, listing only the filter records, but is there a trick into reading the grid data (within my RGPle program) and only processing the filtered records on the page?
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Reading a subfile grid with filtering turn on
You would have to code something to make it work. You would have to loop thru and determine which rows are filtered in Javascript, then somehow send that info back to the RPG program.
One way would be to put a hidden field in the subfile and set that from JavsaScript. Then the RPG could read all of the records but ignore the ones where the hidden field was not set by JS to indicate that the row was filtered.
One way would be to put a hidden field in the subfile and set that from JavsaScript. Then the RPG could read all of the records but ignore the ones where the hidden field was not set by JS to indicate that the row was filtered.
-
- Profound User
- Posts: 21
- Joined: Mon Dec 15, 2014 5:21 pm
- First Name: Randy
- Last Name: Heinz
- Company Name: Southwestern Motor Transport
- Phone: 210.662.3272
- Address 1: 4600 Goldfield
- City: San Antonio
- State / Province: Texas
- Zip / Postal Code: 78218
- Country: United States
- Contact:
Re: Reading a subfile grid with filtering turn on
Within my Grid1, I added a hidden field name OPT
Which event trigger would I use for this javascript?
var myGrid = getObj("Grid1");
for (var r=0; r<myGrid.grid.getRecordCount(); r++) {
if (!myGrid.grid.isRowFilteredOut(r)) {
myGrid.grid.setDataValue(r, "OPT", "1");
}
}
I've tried OnfilterChange of the grid and Onsubmit of record format, but the hidden OPT field did not change.
Which event trigger would I use for this javascript?
var myGrid = getObj("Grid1");
for (var r=0; r<myGrid.grid.getRecordCount(); r++) {
if (!myGrid.grid.isRowFilteredOut(r)) {
myGrid.grid.setDataValue(r, "OPT", "1");
}
}
I've tried OnfilterChange of the grid and Onsubmit of record format, but the hidden OPT field did not change.
-
- Profound User
- Posts: 22
- Joined: Fri Jan 29, 2016 11:15 am
- First Name: sam
- Last Name: huffman
- Company Name: gmdsolutions
- Phone: 7122624520
- Address 1: 2311 W 18th ST
- City: Spencer
- State / Province: Iowa
- Zip / Postal Code: 51301
- Country: United States
- Contact:
Re: Reading a subfile grid with filtering turn on
Randy,
I've used that exact same code in the OnfilterChange event and it has worked for me. I would double check your grid/field naming. Based on the JavaScript you posted you may need to change some of the following: "Grid1" has to be the ID property of the grid and "OPT" has the be the bound variable name of the hidden field.
var myGrid = getObj("Grid1");
for (var r=0; r<myGrid.grid.getRecordCount(); r++) {
if (!myGrid.grid.isRowFilteredOut(r)) {
myGrid.grid.setDataValue(r, "OPT", "1");
}
}
Sam
I've used that exact same code in the OnfilterChange event and it has worked for me. I would double check your grid/field naming. Based on the JavaScript you posted you may need to change some of the following: "Grid1" has to be the ID property of the grid and "OPT" has the be the bound variable name of the hidden field.
var myGrid = getObj("Grid1");
for (var r=0; r<myGrid.grid.getRecordCount(); r++) {
if (!myGrid.grid.isRowFilteredOut(r)) {
myGrid.grid.setDataValue(r, "OPT", "1");
}
}
Sam
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Reading a subfile grid with filtering turn on
onsubmit is too late.... the data to be sent to the server has already been gathered by that point. But, onfilterchange should work.
Make sure your hidden field is input-capable (i.e. a textbox with visibility = hidden). An output field won't work because they are never sent back to RPG, being output only.
Make sure your hidden field is input-capable (i.e. a textbox with visibility = hidden). An output field won't work because they are never sent back to RPG, being output only.
Who is online
Users browsing this forum: No registered users and 0 guests