Information générale
Catégorie:
Gestionnaire d'écran & Écrans
>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
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement