General information
Category:
Forms & Form designer
>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()
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only