MR . RAO
PLEASE look SETWHERE IN TDOLPHIN
I explain :
Through setwhere I can do filter and pages and even order a grid by clicking on the header
VIDEO :
https://www.youtube.com/watch?v=ybPAC1_jm2M 1. HEADER E FOOTER CLICL
************************************************************************************
AEval(::oBrw[1]:aCols,{|o| o:bLClickFooter := o:bLClickHeader := Build_CodeBlock_Order(::oDb_prod)})
************************************************************************************
2. FUNCTION CALLED
**************************************
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
3. TDOLPHIN SETs
********************************************************************************
METHOD SetNewFilter( nType, cFilter, lRefresh )
METHOD SetWhere( cWhere, lRefresh ) INLINE ::SetNewFilter( SET_WHERE , cWhere , lRefresh )
METHOD SetGroup( cGroup, lRefresh ) INLINE ::SetNewFilter( SET_GROUP , cGroup , lRefresh )
METHOD SetHaving( cHaving, lRefresh ) INLINE ::SetNewFilter( SET_HAVING, cHaving, lRefresh )
METHOD SetOrder( cOrder, lRefresh ) INLINE ::SetNewFilter( SET_ORDER , cOrder , lRefresh )
METHOD SetLimit( cLimit, lRefresh ) INLINE ::SetNewFilter( SET_LIMIT , cLimit , lRefresh )
********************************************************************************
***********************************************************
METHOD SetNewFilter( nType, cFilter, lRefresh ) CLASS TDolphinQry
************************************************************
LOCAL cOldFilter
LOCAL l := .T.
DEFAULT lRefresh TO .T.
SWITCH nType
CASE SET_WHERE
cOldFilter = ::cWhere
::cWhere = cFilter
EXIT
CASE SET_GROUP
cOldFilter = ::cGroup
::cGroup = cFilter
EXIT
CASE SET_HAVING
cOldFilter = ::cHaving
::cHaving = cFilter
EXIT
CASE SET_ORDER
cOldFilter = ::cOrder
::cOrder = cFilter
EXIT
CASE SET_LIMIT
cOldFilter = ::cLimit
IF ValType( cFilter ) == "C"
::cLimit = cFilter
ELSEIF ValType( cFilter ) == "N"
::cLimit = AllTrim( Str( cFilter ) )
ENDIF
EXIT
ENDSWITCH
if ::bOnNewFilter != NIL
// if you want change query, do it here,
// return .F. to skip BuildQuery and call BuildDatas()
// return .T. to call BuildQuery()
// isn't recommended return .T. with Sub-Select
l = Eval( ::bOnNewFilter, Self, nType )
// Convert automatically to logical value
l = ValType( l ) == "L" .and. l
endif
if l
if !empty(::cWhereOld) // LUIZ ANTONIO
IF !::cWhereOld $ ::cWhere
::cWhere := "("+::cWhereOld+")" + if(!empty(::cWhere)," and ("+ ::cWhere+")","")
endif
endif
::cQuery := ::BuildQuery( ::aColumns, ::aTables, ::cWhere, ::cGroup, ::cHaving, ::cOrder, ::cLimit )
else
::BuildDatas( ::cQuery )
endif
IF lRefresh
::LoadQuery( .F. )
ENDIF
RETURN cOldFilter