Page 1 of 1

Row selection in database driven grid

Posted: Fri May 04, 2018 11:14 am
by jwurst
I've got a grid control that's loaded using the "custom sql" property. Now I need to do row selection. I tried turning it on by setting "row selection" to single. This doesn't work. Clicking on the rows doesn't result in selection. I can get the row# from javascript on click or double click, but I can't find a way to get anything from that row when I'm operating the grid/subfile in this way. Does anyone have any idea how to make row selection work? I need to find some way to tell the program which row was selected.

Re: Row selection in database driven grid

Posted: Fri May 04, 2018 7:17 pm
by Kaylee Law
Hello jwurst,

If you create a hidden text box on the screen and bind it to a RPG field, you can then use the onrowclick event to set the value of the hidden text box to the row number that you want to return to the RPG program.

This method of course will not show the row as selected in the subfile, but if you submitting the screen with something like a pui.click() also in the same onrowclick event, the end user may not need to see which row was selected.

Would this method work for you?

Re: Row selection in database driven grid

Posted: Mon May 07, 2018 11:54 am
by jwurst
I can use this, but not very well. The problem is the row number is only marginally useful in the RPG program behind. The program has to re-run the query with a wrapper around it to select by row number. That's the only way I've found to get back to the correct record.

Besides the inelegance of having to run a fairly heavy weight query to get figure out what data is in the row, Doing this also results in me having to turn off the ability to sort the grid by clicking on the headings. Otherwise the row number becomes meaningless. I would really like to have the sorting feature turned on.

Oh well. In this particular case this is still better than having to load the grid row by row from the RPG.

Re: Row selection in database driven grid

Posted: Mon May 07, 2018 8:12 pm
by SeanTyree
Hello,

Instead of populating the hidden field with the row number and regenerating the data in the query, your onclick could pull the key information (or whatever is needed to continue with the selected row) and populate that in the hidden field. The a pui.click could react to the data populated in the hidden field.

Sean

Re: Row selection in database driven grid

Posted: Mon May 07, 2018 9:16 pm
by Scott Klement
It's not clear why you're using a database driven grid for this program? Generally, when people want data that's returned back to their program, they don't use a DB-driven grid, because it has no way of returning data back.... since no variables are configured for a DB-driven grid, there's nothing in the record format to communicate data to your program.

DB-driven grids are typically only used for read-only grids. when you need more features, people typically switch to a normal grid, loaded from the program. Then you can use row selection if you like, or whatever else.

If it's really important to use a DB-driven grid for some reason (for example, because it can bypass RPG's 9999 row limit) then you could certainly return the actual contents of the row rather than just the RRN, as Sean suggests. The contents would be retrieved using the getCellValue() API documented here: http://www.profoundlogic.com/docs/pages ... Id=4849913