Como filtrar un Xbrowse con Array?

Como filtrar un Xbrowse con Array?

Postby FranciscoA » Sun Mar 01, 2015 4:23 pm

Hola amigos, pues eso.
Tengo un xbrowse con array (centenares de documentos), el cual necesito filtrar por un documento, segun su numero.
Pueden suministrar un pequeño ejemplo?
Gracias-
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2158
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Como filtrar un Xbrowse con Array?

Postby nageswaragunupudi » Sun Mar 01, 2015 4:54 pm

If you use recent versions, xbrowse provides incremental filters on array browse too
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Como filtrar un Xbrowse con Array?

Postby FranciscoA » Mon Mar 02, 2015 2:08 am

Thanks, Mr. Nages.
I will take a look to my xbrowse.
Regards
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2158
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Como filtrar un Xbrowse con Array?

Postby nageswaragunupudi » Mon Mar 02, 2015 7:15 am

Code: Select all  Expand view

#include "fivewin.ch"
#include "xbrowse.ch"

function Main()

   local aData[ 20000 ]
   local aSub
   local oDlg, oFont, oBrw, n, r
   local bFilter  := { |x| x[ 1 ] % 3 == 0 }  // can be any other filter cond

   // Initialize Array
   for n := 1 to 20000
      aData[ n ]  := { HB_RandomInt( 10001, 99999 ) }
   next
   //

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 300,600 PIXEL FONT oFont

   @ 10,10 XBROWSE oBrw SIZE -10,-30 PIXEL OF oDlg DATASOURCE aData ;
      COLUMNS 1,1 HEADERS "SlNo", "Data" ;
      PICTURES "99999", "999,999" ;
      CELL LINES NOBORDER FOOTERS

   oBrw:aCols[ 1 ]:bEditValue := { || oBrw:nArrayAt }
   oBrw:aCols[ 1 ]:bFooter    := { || oBrw:nLen }

   oBrw:CreateFromCode()

   @ 275, 10 BUTTON "SetFilter" SIZE 40,12 PIXEL OF oDlg ACTION ;
      ( If( aSub == nil, ( aSub := {}, AScan( aData, { |x| If ( Eval( bFilter, x ), AAdd( aSub, x ), nil ) } ) ), nil ), ;
        n := oBrw:aRow, r := oBrw:nRowSel, oBrw:aArrayData := aSub, oBrw:Refresh( .t. ), ;
        oBrw:nArrayAt := Max( 1, AScan( aSub, { |x| x == n } ) ), ;
        oBrw:nRowSel := r, ;
        oBrw:SetFocus() )
   @ 275, 55 BUTTON "ClearFilter" SIZE 40,12 PIXEL OF oDlg ACTION ;
      ( n := oBrw:aRow, r := oBrw:nRowSel, oBrw:aArrayData := aData, oBrw:Refresh( .t. ), ;
        oBrw:nArrayat := Max( 1, AScan( aData, { |x| x == n } ) ), ;
        oBrw:nRowSel := r, ;
        oBrw:SetFocus() )

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Como filtrar un Xbrowse con Array?

Postby Euclides » Mon Mar 02, 2015 2:31 pm

Thanks, Mr. Nages!
And how it would be with arrays in the lines?
TIA & Regards
Euclides
User avatar
Euclides
 
Posts: 156
Joined: Wed Mar 28, 2007 1:19 pm

Re: Como filtrar un Xbrowse con Array?

Postby FranciscoA » Mon Mar 02, 2015 3:12 pm

Excellent example, Mr. Rao. I'll work on it .
Thank you for your magnificent support.
Greetings .
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2158
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Como filtrar un Xbrowse con Array?

Postby FranciscoA » Mon Mar 02, 2015 3:50 pm

Thank you so much , Mr. Rao.
Based on your example could solve my problem.
Best regards.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2158
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 49 guests