How to enumerate rows in a grid?  
Author Message
Robert Winter





PostPosted: Visual FoxPro General, How to enumerate rows in a grid? Top

I have a grid that has an SQL statement as a recordSource. Within that query, one of the columns returned is a key index for that record. I'd like to use the DELETE mark at the leftmost of the grid as sort of a multi-select. A user will "mark" records, then I will perform a process on each of the marked records once a separate button is chosen.

My question is, since the grid source is not a table, how do I scan the grid and see the DELETED status of each row


Visual FoxPro2  
 
 
CetinBasoz





PostPosted: Visual FoxPro General, How to enumerate rows in a grid? Top

In VFP grid source is ALWAYS a table (well it might be a cursor but a cursor is just another table). In other words if you don't dig into differences between them you might simply think a cursor and table as equal (at least would work for your case).

-First for you to be able to mark as deleted the cursor should be readwrite. ie:

with myGrid
.RecordsourceType = 4
.RecordSource = "select * from customer into cursor crsCustomer readwrite"
endwith

-And of course "set deleted off" - otherwise though it might look like it's working you'd get weird visual effects.

Then when user clicks the buttn you m ight scan...endscan within crsCustomer. ie:

select crsCustomer
scan for deleted()
* ...
endscan

or just collect the ids of deleted and use that in a subquery (and say update or report out). ie:

update customer set Country = "New Country" where cust_id in (select cust_id from crsCustomer where deleted())

etc etc

Or you might get the public version of MultiSelectGrid class from universalthread.com downloads.