El ejemplo que te mande hace lo que pides, ami parecer debes usar filtros y scopes para evitar hacer un índice que fuera nombre+Fecha, otro para vehiculo+fecha, etc...
te voy a cambiar el orden del ejemplo para quelo veas...
- Code: Select all Expand view
@ 8, 0 TABS oTab of oChild;
SIZE oChild:nWidth()-80, 12 ;
PROMPTS "&Fecha","&Nombre","&Apellido" ;
COLOR CLR_BLACK, nRGB(226,226,208) ;
PIXEL ACTION ( OrdSetFocus(oTab:nOption), ;
Filtrar( aVar, oTab:nOption ), ;
test->( dbgotop() ), oBrw:Refresh( .t. ))
oChild:oBottom = oTab
la funcion filtrar cambia el orden de los case
- Code: Select all Expand view
Function Filtrar( aVar, nOpc, oBrw )
local cFilter := ""
local bFilter
local uOrderBottom := NIL
local uOrderTop := NIL
default nOpc := 3
test->( ordsetfocus( nOpc ) )
test->( DBCLEARFILTER() )
do case
case nOpc == 2
if !empty( aVar[ 1 ] )
uOrderTop := TRIM(aVar[ 1 ])
endif
if !empty( aVar[ 2 ] )
uOrderBottom := TRIM(aVar[ 2 ])
else
if !empty( aVar[ 1 ] )
uOrderBottom := TRIM(aVar[ 1 ])
endif
endif
if !empty( aVar[ 3 ] )
cFilter += ( if ( empty( cFilter ), "test->last >= '", " .and. test->last >='" ) + TRIM(aVar[ 3 ]) + "'" )
endif
if !empty( aVar[ 4 ] )
cFilter += ( if ( empty( cFilter ), "test->last <= '", " .and. test->last <= '" ) + TRIM(aVar[ 4 ]) + "'" )
else
if !empty( aVar[ 3 ] )
cFilter += ( if ( empty( cFilter ), "test->last <= '", " .and. test->last <= '" ) + TRIM(aVar[ 3 ]) + "'" )
endif
endif
cFilter += ( if ( empty( cFilter ), "test->hiredate >= CTOD('", " .and. test->hiredate >= CTOD('" ) + dtoc( aVar[ 5 ] ) + "')" )
cFilter += ( if ( empty( cFilter ), "test->hiredate <= CTOD('", " .and. test->hiredate <= CTOD('" ) + dtoc( aVar[ 6 ] ) + "')" )
case nOpc == 3
if !empty( aVar[ 3 ] )
uOrderTop := TRIM(aVar[ 3 ])
endif
if !empty( aVar[ 4 ] )
uOrderBottom := TRIM(aVar[ 4 ])
else
if !empty( aVar[ 3 ] )
uOrderBottom := TRIM(aVar[ 3 ])
endif
endif
if !empty( aVar[ 1 ] )
cFilter += ( if ( empty( cFilter ), "test->last >= '", " .and. test->last >= '" ) + TRIM(aVar[ 1 ]) + "'" )
endif
if !empty( aVar[ 2 ] )
cFilter += ( if ( empty( cFilter ), "test->last <= '", " .and. test->last <= '" ) + TRIM(aVar[ 2 ]) + "'" )
else
if !empty( aVar[ 1 ] )
cFilter += ( if ( empty( cFilter ), "test->last <= '", " .and. test->last <= '" ) + TRIM(aVar[ 1 ]) + "'" )
endif
endif
cFilter += ( if ( empty( cFilter ), "test->hiredate >= CTOD('", " .and. test->hiredate >= CTOD('" ) + dtoc( aVar[ 5 ] ) + "')" )
cFilter += ( if ( empty( cFilter ), "test->hiredate <= CTOD('", " .and. test->hiredate <= CTOD('" ) + dtoc( aVar[ 6 ] ) + "')" )
case nOpc == 1
uOrderTop := aVar[ 5 ]
uOrderBottom := aVar[ 6 ]
if !empty( aVar[ 1 ] )
cFilter += ( if ( empty( cFilter ), "test->last >= '", " .and. test->last >= '" ) + TRIM(aVar[ 1 ]) + "'" )
endif
if !empty( aVar[ 2 ] )
cFilter += ( if ( empty( cFilter ), "test->last <= '", " .and. test->last <= '" ) + TRIM(aVar[ 2 ]) + "'" )
else
if !empty( aVar[ 1 ] )
cFilter += ( if ( empty( cFilter ), "test->last <= '", " .and. test->last <= '" ) + TRIM(aVar[ 1 ]) + "'" )
endif
endif
if !empty( aVar[ 3 ] )
cFilter += ( if ( empty( cFilter ), "test->last >= '", " .and. test->last >='" ) + TRIM(aVar[ 3 ]) + "'" )
endif
if !empty( aVar[ 4 ] )
cFilter += ( if ( empty( cFilter ), "test->last <= '", " .and. test->last <= '" ) + TRIM(aVar[ 4 ]) + "'" )
else
if !empty( aVar[ 3 ] )
cFilter += ( if ( empty( cFilter ), "test->last <= '", " .and. test->last <= '" ) + TRIM(aVar[ 3 ]) + "'" )
endif
endif
endcase
test->( ordscope( 0, nil ) )
test->( ordscope( 1, nil ) )
test->( ordscope( 0, uOrderTop ) )
test->( ordscope( 1, uOrderBottom ) )
if !empty( cFilter )
TEST->( DbSetFilter( &( "{||" + cFilter + "}" ), cFilter ) )
endif
return .t.
cambie el orden del TABS ahora "FECHA" esta primero, al momento que creas el browse ya esta creado el
"SCOPE" en "FECHA"(hiredate) y se
"FILTRA" por los demas datos (FIRST Y LAST)...
Cuando cambias el TABS, es decir si te mueves a NOMBRE, se cambia el
"SCOPE" a "NOMBRE"(First) te elimina el
"SCOPE" de "FECHA" y te lo transforma en
"FILTRO" para poder mantener la misma visualizacion anterior
(Siempre tengo que delimitar el día de hoy) pero ahora ordenado por "NOMBRE", igualmente si tenias algun tipo de filtro en "APELLIDO"(last) lo mantiene...
cuando te mueves a "APELLIDO", hace la misma operacion...
se mantiene el
FILTRO/SCOPE por "FECHA"que creaste al hacer el browse, lo que pasa es es se va "jugando" con estos... siempre vas a tener un
SCOPE activo dependiendo de la selecion que tengas en el TABS y los demas datos seran
FILTROS, espero hacerme entender...
debes adaptarlo a tu sistema, hacer bien OrdSetFocus ( yo lo hice diferente a como tulo hiciste )