Hola amigos
Al utilizar una base de datos filtrada, ya sea con setfilter o con ordscope, me tarda un mundo en abrir el xbrowse, no se si será porque lo tendré mal estructurado o porque es asÃ.
Saludos
Jose Luis
Saludos
Jose Luis
Hola amigos
Al utilizar una base de datos filtrada, ya sea con setfilter o con ordscope, me tarda un mundo en abrir el xbrowse, no se si será porque lo tendré mal estructurado o porque es asÃ.
Saludos
Jose Luis
publica un ejemplo del mismo para visualizar mejor el posible problema, incluye el filtrado y la creacion del xbrowse
@ 30, 0 XBROWSE oLbx COLUMNS "Fecha","Fecha1","pro1","pobla1","Conductor","nConductor","Realizado","Incidencia","Operador";
HEADER " F.Aviso "," F. Recog. ", " Recoger en ","Poblacion "," Cond. "," Nombre "," R ","Incidencia","Operador" ;
COLSIZES 55,55,180,100,40,150,15,100,150;
OF oDlg ALIAS aAlias[30];
ON LEFT DBLCLICK (iif(!(aAlias[30])->(eof()) .and. Publicas:cAccesoM,(cTitulo:="Visualización de Avisos ",Entalba(cTitulo,"V",aAlias),oLbx:Refresh()),.T.));
AUTOCOLS LINES CELL
oLbx:bKeyChar := { | nKey, nFlags | ;
iif (nKey == 43 .or. nKey == 65 .or. nKey == 97,;
(entalba(cTitulo,"A",aAlias), oLbx:Refresh()),),;
iif (nKey == 84 .or. nKey == 116,;
(borrame(aAlias),oLbx:UpStable(), oLbx:Refresh()),),;
iif (nKey == 77 .or. nKey == 109, ;
(entalba(cTitulo,"M",aAlias),oLbx:Refresh()),),;
iif (nKey == 66 .or. nKey == 98,;
(Borrar(aAlias[30],(aAlias[30])->pro1,'Aviso al cliente: '),oLbx:UpStable(), oLbx:Refresh()), ),;
iif (nKey == 77 .or. nKey == 109, ;
(entalba(cTitulo,"M",aAlias),oLbx:Refresh() ), ) }
oLbx:nMarqueeStyle := MARQSTYLE_HIGHLROW
oLbx:bClrGrad := { | lInvert | If( ! lInvert, ;
{ { 0.50,8638963,13565951 }, ;
{ 0.50,13565951,8638963 } }, ;
{ { 0.50,768756,13565951 }, ;
{ 0.50,13565951,768756 } } ) }
oLbx:bClrStd := { || If( ( (oLbx:cAlias)->(OrdKeyNo()) % 2 ) == 0, { CLR_BLACK, RGB(242,247,252) }, { CLR_BLACK, RGB(226,226,208) } ) }
oLbx:lColDividerComplete := .F.
oLbx:lHScroll:=.F.
oLbx:CreateFromCode()
oLbx:l2007 := (.T.)
oDlg:oClient := oLbx
@ 8, 0 TABS oTab of oDlg;
SIZE oDlg:nWidth()-80, 12 ;
PROMPTS "&Fecha Aviso","Fecha &Recogida","C&liente","&Conductor","&Realizado" ;
COLOR CLR_BLACK, nRGB(226,226,208) ;
PIXEL;
ACTION ((aAlias[30])->(Ordsetfocus(cambia(oTab:nOption))),oLbx:Refresh())
oDlg:oBottom = oTabstatic function cambia(recibe)
local devuelve
if recibe=1
devuelve:="Fecha"
endif
if recibe=2
devuelve:="Fecha1"
endif
if recibe=3
devuelve:="pro1"
endif
if recibe=4
devuelve:="Conductor"
endif
if recibe=5
devuelve:="Realizado"
endif
return devuelve Set filter to (aAlias[30])->Fecha1 = Date()realmente yo no veo ningun problema, lo que me extraña es que te dañe los cdx cuando aplicas el filtro, yo particularmente siempre uso ORDSCOPE.
ORDSCOPE( 0, NIL )
ORDSCOPE( 1, NIL )
ORDSCOPE( 0, FiltroSuperior )
ORDSCOPE( 1, FiltroInferior )
y los filtro los hago con:
( cAlias )->( dbsetfilter({|| CampoFiltro == uValor }, "CampoFiltro == uValor" ) )
pero preferiblemente siempre con ORDSCOPE creo que es mucho mas rapido y si necesito un filtro puedo hacerlo dentro del rango del ORDSCOPE
Realmente siempre suelo utilizar scopes pero cuando tengo tabs que cambian el orden del tag no se como hacerlo:
cFecha:=Date()
(aAlias[30])->(ordscope(0,Dtos(cFecha)))
(aAlias[30])->(ordscope(1,Dtos(cFecha)))
y sólo veo los registros de hoy
Pero si ahora quiero ver sólo los registros de hoy, pero ordenados por nombre, si pongo
(aAlias[30])->(ordsetfocus("Nombre"))
Pues ahora me los muestra por orden de nombre, pero ya no me muestra sólo los registros de hoy.
Hay alguna manera de hacer ésto sólo utilizando scopes?
Saludos
Jose Luis
#include "fivewin.ch"
#include "xbrowse.ch"
STATIC oWnd
FUNCTION MainTest()
local oWnd
local aGet := array( 6 )
local aVar := array( 6 )
local cFiltro := ""
aVar[ 1 ]:= space( 20 )
aVar[ 2 ]:= space( 20 )
aVar[ 3 ]:= space( 20 )
aVar[ 4 ]:= space( 20 )
aVar[ 5 ]:= date()
aVar[ 6 ]:= date()
define dialog oDlg from 5,0 to 40,60
@ 1,1 SAY "DESDE NOMBRE :" OF oDlg
@ 2,1 SAY "HASTA NOMBRE :" OF oDlg
@ 3,1 SAY "DESDE APELLIDO:" OF oDlg
@ 4,1 SAY "HASTA APELLIDO:" OF oDlg
@ 5,1 SAY "DESDE FECHA :" OF oDlg
@ 6,1 SAY "HASTA FECHA :" OF oDlg
@ 1,10 GET aGet[ 1 ] VAR aVar[ 1 ] OF oDlg
@ 2,10 GET aGet[ 2 ] VAR aVar[ 2 ] OF oDlg
@ 3,10 GET aGet[ 3 ] VAR aVar[ 3 ] OF oDlg
@ 4,10 GET aGet[ 4 ] VAR aVar[ 4 ] OF oDlg
@ 5,10 GET aGet[ 5 ] VAR aVar[ 5 ] OF oDlg
@ 6,10 GET aGet[ 6 ] VAR aVar[ 6 ] OF oDlg
@ 10,1 button oBtn prompt "Aceptar" action ( oDlg:end(),Prueba( aVar ) )
@ 10,10 button oBtn2 prompt "Salir" action ( dbcloseall(), oDlg:end() )
activate dialog oDlg
return
procedure Prueba( aVar )
local oChild, oBrw, oCol
local nFor
LOCAL oTab
local cFiltro
REQUEST DBFCDX
rddsetdefault( "DBFCDX" )
USE TEST NEW
set index to test
Filtrar( aVar )
TEST->( DBGOTOP() )
DEFINE WINDOW oChild TITLE "Ejemplo"
oBrw := TXBrowse():New( oChild )
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLCELL
oBrw:nColDividerStyle := LINESTYLE_BLACK
oBrw:nRowDividerStyle := LINESTYLE_BLACK
oBrw:lColDividerComplete := .t.
oBrw:SetRDD()
for nFor := 1 to len( oBrw:aCols )
oCol := oBrw:aCols[ nFor ]
oCol:nEditType := 1
oCol:bOnPostEdit := {|o, v, n| iif( n != VK_ESCAPE, FieldPut( o:nCreationOrder, v ), ) }
next
oBrw:CreateFromCode()
oChild:oClient := oBrw
@ 8, 0 TABS oTab of oChild;
SIZE oChild:nWidth()-80, 12 ;
PROMPTS "&Nombre","&Apellido","Fecha" ;
COLOR CLR_BLACK, nRGB(226,226,208) ;
PIXEL ACTION ( OrdSetFocus(oTab:nOption), ;
Filtrar( aVar, oTab:nOption ), ;
test->( dbgotop() ), oBrw:Refresh( .t. ))
oChild:oBottom = oTab
ACTIVATE WINDOW oChild ON INIT ( oBrw:SetFocus() )
return
procedure Filtrar( aVar, nOpc )
local cFilter := ""
local bFilter
local uOrderBottom := NIL
local uOrderTop := NIL
default nOpc := 1
test->( ordsetfocus( nOpc ) )
test->( DBCLEARFILTER() )
do case
case nOpc == 1
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 == 2
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 == 3
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 WITH OBJECT oBrwSearch:= TXBrowse():New( oDlg )
:bBof := :bEof := { || .t. }
:bKeyCount := :bKeyNo := :bBookMark := { || 0 }
WITH OBJECT :AddCol()
:bStrData := { || Space(100) }
:cHeader := "NOMBRE DEL TITULO"
:nWidth := 370
END
.... mas columnas ....
:CreateFromResource(800)
ENDFUNCTION Filtro( oBrw )
.... Se hace el filtro ....
:cAlias:= "LIBROSBOOK"
oBrw:SetRDD( .F., .F. )
oBrw:aCols[01]
oBrw:bStrData := { || libros->CAMPO1 }
oBrw:cHeader := "NOMBRE DEL TITULO"
oBrw:aCols[02]
oBrw:bStrData := { || libros->ISBN }
oBrw:cHeader := "ISBN"
.... mas columnas ....
oBrw:Refresh()
RETURN NILFUNCTION Filtro( oBrw )
.... Se hace el filtro ....
.... mas columnas ....
oBrw:bBof := { || LIBROSBOOK->( bof() ) }
oBrw:bEof := { || LIBROSBOOK->( eof() ) }
oBrw:bKeyCount := {|| LIBROSBOOK->( OrdKeyCount() ) }
oBrw:bKeyNo := {| n | iif( n == nil,;
LIBROSBOOK->( OrdKeyNo() ),;
LIBROSBOOK->( OrdKeyGoto( n );
) ) }
oBrw:bBookMark := {| n | If( n == nil,;
LIBROSBOOK->( RecNo() ),;
LIBROSBOOK->( DBGoTo( n ) ) ) }
oBrw:Refresh( .t. ) // <===PENDIENTE... AGREGA .T.
RETURN NILEn el ejemplo que me mandas, primero hace un scope y una vez hecho, hace el filtro, pero como te he explicado antes, no puedo hacer eso.
Siempre tengo que delimitar el dÃa de hoy, por lo tanto lo primero que tengo que hacer es ordscope sobre la fecha de hoy.
Una vez delimitado, ya no tengo que filtrar nada, sólo cambiar el tag, osea Ordsetfocus("Nombre"), por lo que se fastidia el scope anterior, y me presenta organizado por nombre, pero ya sin la delimitación de la fecha de hoy.
Para ello, tendrÃa que tener un Ãndice que fuera nombre+Fecha, otro para vehiculo+fecha, etc...
No se si me explico
Saludos
Jose Luis
@ 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 = oTabFunction 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. oBrw:bGoTop := NIL
oBrw:bGoBottom := NIL
oBrw:bSkip := NIL
oBrw:bBof := NIL
oBrw:bEof := NIL
oBrw:bBookMark := NIL
oBrw:bKeyNo := NIL
oBrw:bKeyCount := NIL
.....COLUMNAS...
oBrw:SetRDD()
oBrw:Refresh(.T.)JoseLuis wrote:En el ejemplo que me mandas, primero hace un scope y una vez hecho, hace el filtro, pero como te he explicado antes, no puedo hacer eso.
- Siempre tengo que delimitar el dÃa de hoy, por lo tanto lo primero que tengo que hacer es ordscope sobre la fecha de hoy.
- Una vez delimitado, ya no tengo que filtrar nada, sólo cambiar el tag, osea Ordsetfocus("Nombre"), por lo que se fastidia el scope anterior, y me presenta organizado por nombre, pero ya sin la delimitación de la fecha de hoy.
- Para ello, tendrÃa que tener un Ãndice que fuera nombre+Fecha, otro para vehiculo+fecha, etc...