Page 1 of 1
Select All w/ grid checkboxes
Posted: Thu Mar 10, 2016 2:30 pm
by SeanTyree
I have a grid with checkboxes for selection. I am adding a 'Select All' function in Javascript by spinning through the checkbox.rows and using the changeElementValue to set the checkboxes to checked. The problem is that rows that are not displayed (below the bottom) do not get changed -when I scroll down they are not checked.
Is this a known issue that I will need to return to the RPG and update the SFL, or is there possibly something that I am missing?
Thanks,
Sean
Re: Select All w/ grid checkboxes
Posted: Fri Mar 11, 2016 7:16 pm
by matt.denninghoff
Right now what you would like to do isn't possible in JavaScript. The grid displays a fixed number of DOM elements, and scrolling causes some to be created and others destroyed. We would need to create an API that would allow you to manipulate what is not visible on the grid.
If you're interested, we can make this a feature request.
Re: Select All w/ grid checkboxes
Posted: Fri Mar 11, 2016 8:31 pm
by SeanTyree
Matt,
Thanks for the info. It was what I suspected, so I changed it to return to the RPG where I update the SFL records w/ the checkbox selected.
Sean
Re: Select All w/ grid checkboxes
Posted: Thu May 05, 2016 11:14 am
by ZoeW
Hi Sean
I know it's been a while since you posted, but I wondered if you tried iterating through the grid and using
setDataValue to check the boxes?
I use something similar to retrieve a value from every row in a grid, even those that are not displayed, so I would assume that setDataValue might work in the same way.
e.g.
Code: Select all
for (i = 1; i < total_rows; i++){
myUnits = parseInt(getObj("sfl1").grid.getDataValue(i, "s1newunits"),10,10);
// do some stuff with myUnits...
}
Re: Select All w/ grid checkboxes
Posted: Fri May 06, 2016 10:46 am
by Scott Klement
There's a known limitation to setDataValue() at this point -- it can set the value of any row in a grid, but it can't mark an input-capable field as "modified" unless that field has previously been shown on the display. Only values that are marked as "modified" will be sent back to the server.
So it will work fine if all of the rows have previously been on the display. (It will also work fine for output-only fields, since these don't need to be sent back to the server.)
But, for the "checkbox" scenario, it'll really only work for rows that were on the display before setDataValue() was run -- or for rows where the user later goes and makes a change to the checkbox field to mark it modified. So not ideal for that.
A better solution is to just send control back to the RPG program, have the RPG program loop through the subfile and update the checkbox fields, and then re-display the screen. That is easy to code and will work perfectly.
Re: Select All w/ grid checkboxes
Posted: Fri May 06, 2016 12:40 pm
by SeanTyree
A better solution is to just send control back to the RPG program, have the RPG program loop through the subfile and update the checkbox fields, and then re-display the screen. That is easy to code and will work perfectly.
Scott,
This is the solution that I used.
Thanks,
Sean