when I click on the header
- Code: Select all Expand view
REDEFINE XBROWSE ::oBrw ID 100 OF ::ODLG AUTOSORT
ADD TO ::oBrw DATA ::oDb_prod:servico
ADD TO ::oBrw DATA ::oDb_prod:pmestre
ADD TO ::oBrw DATA ::oDb_prod:produto
ADD TO ::oBrw DATA ::oDb_prod:barra
ADD TO ::oBrw DATA ::oDb_prod:descricao
ADD TO ::oBrw DATA ::oDb_prod:unidade
ADD TO ::oBrw DATA ::oDb_prod:ncm
ADD TO ::oBrw DATA ::oDb_prod:lucro PICTURE "@E 99999.99"
ADD TO ::oBrw DATA ::oDb_prod:preco PICTURE "@E 999,999.999"
::oBrw:ACOLS[1]:CHEADER := "TP"
::oBrw:ACOLS[1]:NDATASTRALIGN := AL_CENTER
::oBrw:ACOLS[1]:NHEADSTRALIGN := AL_CENTER
::oBrw:ACOLS[1]:NWIDTH := 40
::oBrw:ACOLS[1]:bLClickHeader := Build_CodeBlock_Order( ::oDb_prod )
::oBrw:ACOLS[2]:CHEADER := "FAMILIA"
::oBrw:ACOLS[2]:NDATASTRALIGN := AL_CENTER
::oBrw:ACOLS[2]:NHEADSTRALIGN := AL_CENTER
::oBrw:ACOLS[2]:NWIDTH := 70
::oBrw:ACOLS[2]:bLClickHeader := Build_CodeBlock_Order( ::oDb_prod )
::oBrw:ACOLS[3]:CHEADER := "PRODUTO"
::oBrw:ACOLS[3]:NDATASTRALIGN := AL_CENTER
::oBrw:ACOLS[3]:NHEADSTRALIGN := AL_CENTER
::oBrw:ACOLS[3]:NWIDTH := 70
::oBrw:ACOLS[3]:bLClickHeader := Build_CodeBlock_Order( ::oDb_prod )
::oBrw:ACOLS[4]:CHEADER := "BARRAS"
::oBrw:ACOLS[4]:NDATASTRALIGN := AL_LEFT
::oBrw:ACOLS[4]:NHEADSTRALIGN := AL_LEFT
::oBrw:ACOLS[4]:NWIDTH := 120
::oBrw:ACOLS[4]:bLClickHeader := Build_CodeBlock_Order( ::oDb_prod )
::oBrw:ACOLS[5]:CHEADER := "DESCRICAO"+CRLF+"PRODUTO"
::oBrw:ACOLS[5]:NDATASTRALIGN := AL_LEFT
::oBrw:ACOLS[5]:NHEADSTRALIGN := AL_LEFT
::oBrw:ACOLS[5]:NWIDTH := 400
::oBrw:ACOLS[5]:bLClickHeader := Build_CodeBlock_Order( ::oDb_prod )
::oBrw:ACOLS[6]:CHEADER := "UN"
::oBrw:ACOLS[6]:NDATASTRALIGN := AL_CENTER
::oBrw:ACOLS[6]:NHEADSTRALIGN := AL_CENTER
::oBrw:ACOLS[6]:NWIDTH := 40
::oBrw:ACOLS[6]:bLClickHeader := Build_CodeBlock_Order( ::oDb_prod )
::oBrw:ACOLS[7]:CHEADER := "NCM"
::oBrw:ACOLS[7]:NDATASTRALIGN := AL_CENTER
::oBrw:ACOLS[7]:NHEADSTRALIGN := AL_CENTER
::oBrw:ACOLS[7]:NWIDTH := 90
::oBrw:ACOLS[7]:bLClickHeader := Build_CodeBlock_Order( ::oDb_prod )
::oBrw:ACOLS[8]:CHEADER := "MARGEM"
::oBrw:ACOLS[8]:NDATASTRALIGN := AL_RIGHT
::oBrw:ACOLS[8]:NHEADSTRALIGN := AL_RIGHT
::oBrw:ACOLS[8]:NWIDTH := 80
::oBrw:ACOLS[8]:bLClickHeader := Build_CodeBlock_Order( ::oDb_prod )
::oBrw:ACOLS[9]:CHEADER := "PREÇO"
::oBrw:ACOLS[9]:NDATASTRALIGN := AL_RIGHT
::oBrw:ACOLS[9]:NHEADSTRALIGN := AL_RIGHT
::oBrw:ACOLS[9]:NWIDTH := 90
::oBrw:ACOLS[9]:bLClickHeader := Build_CodeBlock_Order( ::oDb_prod )
::oBrw:lRecordSelector := .T.
::oBrw:lfooter := .T.
::oBrw:lHScroll := .T.
::oBrw:lVScroll := .T.
::oBrw:NHEADERLINES := 2
::oBrw:NDATALINES := 1
::oBrw:NFOOTERLINES := 1
::oBrw:l2007 := .F.
::oBrw:nRowHeight := 24
::oBrw:NMARQUEESTYLE := 5//MARQSTYLE_HIGHLROW
::oBrw:bClrSelFocus := { ||{ CLR_WHITE, CLR_RED } }
::oBrw:NCOLDIVIDERSTYLE := LINESTYLE_BLACK
::oBrw:NROWDIVIDERSTYLE := LINESTYLE_BLACK
::oBrw:LCOLDIVIDERCOMPLETE := .T.
::oBrw:BCLRSELFOCUS := { || { CLR_WHITE, CLR_RED } }
::oBrw:BKEYDOWN := {|NKEY| ::KEYPRESS( NKEY ) }
::oBrw:SetDolphin( ::oDb_prod )
- Code: Select all Expand view
**************************************
FUNCTION Build_CodeBlock_Order( oQry )
**************************************
RETURN {| nMRow, nMCol, nFlags, oCol | SetOrderDolphin( oCol, oQry ) }
****************************************
function SetOrderDolphin( oCol, oQry )
****************************************
LOCAL aToken
LOCAL cType, cOrder
aToken := HB_ATokens( oQry:cOrder, " " )
IF Len( aToken ) == 1
AAdd( aToken, "ASC" )
ENDIF
cOrder = AllTrim( Lower( aToken[ 1 ] ) )
cType = aToken[ 2 ]
AEval( oCol:oBrw:aCols, {| o | o:cOrder := " " } )
IF oQry:aStructure[ oCol:nCreationOrder ][ 1 ] == cOrder
IF Upper( cType ) == "ASC"
cType = "DESC"
oCol:cOrder = "D"
ELSE
cType = "ASC"
oCol:cOrder = "A"
ENDIF
ELSE
cOrder = oQry:aStructure[ oCol:nCreationOrder ][ 1 ]
cType = "ASC"
oCol:cOrder = "A"
ENDIF
oQry:SetOrder( cOrder + " " + cType )
oCol:oBrw:Refresh()
RETURN NIL