Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting of data in a grid 1

Status
Not open for further replies.

mike2p

Programmer
Jan 21, 2001
6
CY
Hi to all
We need to do the following but we have run out of ideas.
we need to sort the data displayed in a grid by 'date'.
We have tried doing in in the data environment but it does not work.
'date' is a date field in our table called:'dlogbooks.dbf'
So,. any ideas?

Thaknking you in advance
Regards
Mike
 
mike2p

If your table is not indexed on the field DLOGBOOKS.date, index it as follows:-

INDEX ON date TAG date
SET ORDER TO TAG date

or if it is indexed:-

SET ORDER TO TAG date

Chris
 
mike2p

The previous post will set the date in the grid in ascending order

If you want to add the ability to toggle the date order from ascending to descending you could try the following:-

Add a new form property called .lAscendingDate

Locate the .Click() event of the Header in the Column containing DLOGBOOKS.date
and add the following code:-

WITH THISFORM
[tab]IF .lAscendingDate
[tab][tab]SET ORDER TO TAG date ASCE
[tab][tab].lAscendingDate = .F.
[tab]ELSE
[tab][tab]SET ORDER TO TAG date DESC
[tab][tab].lAscendingDate = .T.
[tab]ENDI
[tab].Grid1.Refresh()
ENDW

Clicking on the header of the column will toggle the date order.

Alternatively could add ASCENDING or DESCENDING to SET ORDER TO TAG date as:-

SET ORDER TO TAG date ASCENDING

Hope this helps but doesn't confuse.

Chris
 
how would i do that if I have no indexing on my table (remote view)
 
even with a remote view you can do as ChrisRChamberlain has posted. I would only change one thing.

It is not good practice to use reserved words to name items

INDEX ON date TAG date

I would change to

INDEX ON date TAG ddate
Attitude is Everything
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top