PxPlus User Forum

Main Board => Discussions => Programming => Topic started by: Cedric on September 20, 2024, 03:15:11 PM

Title: grid read next ?
Post by: Cedric on September 20, 2024, 03:15:11 PM
Hi,

I have a grid where all cells are locked except the last column which is a checkbox.  Anyway, the customer asked to be able to do a multi select of cells.  My goal is to simply read all selected cells to toggle the value of the checkbox.

So I started to play with the multiselect for grids and tried to read multiple lines without success.  I mean, I can read the first cells and then the second one by using "grid read next", but how to iterate to the next one?  It loops on the same cell?  Do I need to do something special to just loop on each selected cells by the user?  I've also tried a "grid goto" to force a proper read after the "grid read next", but this "unselects" previous cells.

I'm doing my test with version 18 (local version, not windx) if that matters...

Thanks
Title: Re: grid read next ?
Post by: Mike King on September 20, 2024, 04:48:43 PM
When you say SELECTED do you mean the rows of the grid whose check box is checked?

If so the best solution would be to read the whole grid into a single string using GRID FIND ctlno,0,0,string$.  You can then parse the string row by row (delimited by $0a$), and extract the last column (delimited by SEP).  This will allow you to find which rows to process.

To reset all the check boxes us a GRID WRITE ctlno, lastcolno, 0, ""
... where lastcolno is the column with the check box.
Title: Re: grid read next ?
Post by: Cedric on September 20, 2024, 05:57:14 PM
Hey Mike, no, sorry for the confusion!  I'm really talking about the CELL selection by using the CTRL-MOUSECLICK or SHIFT-MOUSECLICK.

So let'say there's a grid with 30 lines. The user click once on a cell in line 10 and then presses SHIFT and click line 20 from the same column.  I want to read selected cells, so in this case from line 10 to 20.