Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid order columns
Message
De
07/09/1999 06:57:02
 
 
À
06/09/1999 15:31:19
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00261783
Message ID:
00261882
Vues:
26
>how can i get the tip to when the user click on the header of a column of a grid the table in the grid get the order of the field that header the user click???
In the click of the header put this
This.Parent.Parent.ColumnSort(This)

create a method called ColumnSort and put the following code in it

PARAMETER oHeader
LOCAL lnPosition, lcField, lnCount

lcField = SUBSTR(oHeader.Parent.ControlSource, AT('.', oHeader.Parent.ControlSource)+1)

IF oHeader.Parent.Parent.SortFlag = .T. && Do the Sort
thisform.LockScreen = .T.
SELECT(oHeader.Parent.Parent.RecordSource)
lnPosition = RECNO(oHeader.Parent.Parent.RecordSource)
DO CASE
CASE EMPTY(ORDER(oHeader.Parent.Parent.RecordSource)) && No Index Set
FOR lnCount = 1 TO 254
IF !EMPTY(TAG(lnCount)) && Checks for tags in the index
IF UPPER(TAG(lnCount)) = UPPER(lcField)
SET ORDER TO TAG &lcField ASCENDING
EXIT && Exit the loop when a matching tag is found
ENDIF
ELSE
INDEX ON &lcField TAG &lcField ASCENDING
EXIT && Exit the loop when no more tags are found
ENDIF
ENDFOR
oHeader.FontBold = .T.
CASE UPPER(lcField) = ORDER(oHeader.Parent.Parent.RecordSource)
IF NOT DESCENDING() && Order is Ascending
SET ORDER TO TAG &lcField DESCENDING
ELSE && Order is Descending
SET ORDER TO 0
oHeader.FontBold = .F.
ENDIF
OTHERWISE && Different Column
FOR lnCount = 1 TO 254
IF !EMPTY(TAG(lnCount)) && Checks for tags in the index
IF UPPER(TAG(lnCount)) = UPPER(lcField)
SET ORDER TO TAG &lcField ASCENDING
EXIT && Exit the loop when a matching tag is found
ENDIF
ELSE
INDEX ON &lcField TAG &lcField ASCENDING
EXIT && Exit the loop when no more tags are found
ENDIF
ENDFOR
oHeader.Parent.Parent.SetAll("FontBold", .F., "Header")
oHeader.FontBold = .T.
ENDCASE
thisform.Refresh()
GOTO RECORD lnPosition
thisform.LockScreen = .F.
ELSE && Reset the Flag for the next call
oHeader.Parent.Parent.SortFlag = .T.
ENDIF

IF NOT EMPTY(ORDER(oHeader.Parent.Parent.RecordSource))
This.cIndexSet = .T.
ELSE
This.cIndexSet = .F.
ENDIF

oHeader.Parent.Parent.Refresh()
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform