Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sort Grid Columns?
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00000436
Message ID:
00001309
Views:
53
Hi Tom,

Thought you would be interested in seeing how I finally had to code the click() method to work with a variety of grids... one thing I had to contend with is that I wanted the column to sort in that field, even though the ORDER was set to slightly different... ie. cusid is the field, but the ORDER is cusid+DTOC(date) (sales history file). What I ended up doing is setting the TAG to cusid in the database... it then matches the field bound to the column and the column is automatically sorted and in this case, also sorts the dates as well within the cusid.

here's the code... (if you see anything that I've forgotten, let me know!)

Note: I established a property for each grid for the last
SET ORDER TO, so that I could determine if it was ascending
or descending and switch appropriately.

GRDBASE.HEADER.CLICK()

* If Clicked, AND if there is a TAG to this column, then SORT IT.

LOCAL lcSetOrder, lcOrder, lcControlSource

lcSetOrder=This.Parent.Parent.icSetOrder
SELECT (This.Parent.Parent.RecordSource)

FOR i=1 TO TAGCOUNT()
lcOrder=UPPER(TAG(i))
lcControlSource=UPPER(This.Parent.ControlSource)
IF "." $ lcControlSource
lcControlSource=SUBSTR(lcControlSource, ; RAT(".",lcControlSource)+1)
ENDIF

IF lcControlSource==lcOrder
IF !EMPTY(lcSetOrder)
IF "DESCENDING" $ lcSetOrder
SET ORDER TO &lcOrder ASCENDING
ELSE
SET ORDER TO &lcOrder DESCENDING
ENDIF
ELSE
SET ORDER TO &lcOrder ASCENDING
ENDIF

This.Parent.Parent.icSetOrder=SET("ORDER")
This.Parent.Parent.Refresh()

ENDIF
ENDFOR
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform