Page 1 of 2

possible with xBrowse?

Posted: Tue Aug 02, 2011 11:25 am
by mgsoft
Hello.

I would like to know if it is possible to do with xBrowse, so results are updated in runtime mode:

Image

Uploaded with ImageShack.us

See video: http://www.mediafire.com/?dxm8190tuai1yem

Thanks ;)

Re: possible with xBrowse?

Posted: Thu Aug 04, 2011 6:30 pm
by nageswaragunupudi
I prepared a sample for Incremental Filter using \fwh\samples\customer.dbf. The incremental filter is applied to the field "FIRST". You may test this on customer.dbf first and then adopt to your dbf structure and requirements.

Code: Select all

#include 'fivewin.ch'
#include 'ord.ch'
#include 'xbrowse.ch'
#include 'hbcompat.ch'

REQUEST DBFCDX

static cSeek   := ''
static oSeek

function Main()

   local oDlg, oBrw

   RDDSETDEFAULT( "DBFCDX" )
   USE CUSTOMER
   SET ORDER TO TAG FIRST
   GO TOP

   DEFINE DIALOG oDlg SIZE 600,400 PIXEL
   @ 30,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      AUTOCOLS ALIAS "CUSTOMER" CELL LINES NOBORDER

   @ 10,10 SAY oSeek PROMPT cSeek SIZE 100,10 PIXEL ;
      OF oDlg COLOR CLR_BLACK,CLR_YELLOW

   oBrw:bSeek  := nil   

   oBrw:bKeyChar  := { |nKey| KeyChar( oBrw, nKey ) }

   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED

return nil

static function KeyChar( oBrw, nKey )

   If nKey == VK_BACK .and. ! Empty( cSeek )
      ( oBrw:cAlias )->( IncrFilter( oBrw, Left( cSeek, Len( cSeek ) -1 ) ) )
      return 0
   elseIf nKey > 31
      ( oBrw:cAlias )->( IncrFilter( oBrw, cSeek + Chr( nKey ) ) )
      return 0
   Endif

return nil

static function IncrFilter( oBrw, cPattern )

   local cFilter, lFound := .f.
   local nRecNo, cSaveFilt, lStay

   if ValType( cPattern ) == 'C'
      if Empty( cPattern )
         cSeek       := ""
         oSeek:SetText( cSeek )
         SET FILTER TO !DELETED()
         GO TOP
         oBrw:Refresh()
         lFound      := .t.
      else
         cFilter     := 'WildMatch( "*' + Upper(cPattern) + '*", UPPER( FIRST )) .AND. !DELETED()'
         cSaveFilt   := DBFILTER()
         nRecNo      := RECNO()
         lStay       := &cFilter
         SET FILTER TO &cFilter
         GO TOP
         if OrdKeyCount() == 0
            SET FILTER TO &cSaveFilt
            GO TOP
            DBGOTO( nRecNo )
         else
            cSeek    := cPattern
            oSeek:SetText( cSeek )
            if lStay
               DBGOTO( nRecNo )
               oBrw:Refresh()
            else
               oBrw:Refresh( .t. )
            endif
            lFound   := .t.
         endif
      endif
   endif

return lFound
 
Instead of using WildMatch function we could use simple "$" also. But by using WildMatch function, the user can enter wildcard character "?" inside the search expression.

Re: possible with xBrowse?

Posted: Fri Aug 05, 2011 9:34 am
by mgsoft
Thank you very much.

It works perfect.

xBrowse is too much powerfull!!!.

Re: possible with xBrowse?

Posted: Fri Aug 05, 2011 10:44 am
by nageswaragunupudi
xBrowse is too much powerfull!!!
Will become more powerful.
Incremental filters like the above will be provided natively in the XBrowse from the next version.
Then the application code to achieve the above can be as small as:

Code: Select all

#include 'fivewin.ch'
#include 'ord.ch'
#include 'xbrowse.ch'
#include 'hbcompat.ch'

REQUEST DBFCDX

//----------------------------------------------------------------------------//

function Main()

   local oDlg, oBrw

   RDDSETDEFAULT( "DBFCDX" )
   USE CUSTOMER
   SET ORDER TO TAG FIRST
   GO TOP

   DEFINE DIALOG oDlg SIZE 600,400 PIXEL

   @ 30,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      AUTOCOLS AUTOSORT ALIAS "CUSTOMER" CELL LINES NOBORDER

   oBrw:lIncrFilter  := .t.
   oBrw:lSeekWild    := .t.

   @ 10,10 SAY oBrw:oSeek PROMPT oBrw:cSeek SIZE 100,10 PIXEL ;
      OF oDlg COLOR CLR_BLACK,CLR_YELLOW PICTURE '@!'

   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED

return nil

//----------------------------------------------------------------------------//
 

Re: possible with xBrowse?

Posted: Fri Aug 05, 2011 8:03 pm
by mgsoft
Incredible, Mr. Rao.

Also, to search the entire DB:

cFilter := 'hb_WildMatch( "*' + Upper(cPattern) + '*", DbRecordInfo( 9 ))'

But in ADS does not work, it says:

Error ADSCDX/0 Operation not supported


I think it will be very interesting to search in the entire db.


I would like to congratulate you for all the extraordinary work done with xBrowse, and especially your kindness to answer and explain in the forums. A gentleman and great master.

Re: possible with xBrowse?

Posted: Sat Aug 06, 2011 2:34 am
by nageswaragunupudi
Thanks for reminding me about ADS. I realize the need to distinguish ADS in the code under development.

For ADS, particularly client server implementation with large tables, it is desirable that the filter expression can be resolved on the server and if possible optimized.

Instead of using wildmatch function, better to use <expr> $ <fld1>[ + <fld2> ...]. Though this expression is not optimized, used to give me reasonable results on large tables.

For full search, the filter expression you proposed is good for DBFCDX. For ADS, we may better use the FTS syntax and depend on the ADS's beautiful FTS capability

Re: possible with xBrowse?

Posted: Sat Aug 06, 2011 10:53 am
by mgsoft
Thank you very much.

Which is please the equivalent in ADS for cFilter := 'hb_WildMatch( "*' + Upper(cPattern) + '*", DbRecordInfo( 9 ))' , so I can search in all fieds ?

Thank you.

Re: possible with xBrowse?

Posted: Fri Aug 19, 2011 7:57 am
by ukservice
Mr Nao,

Thank you very much for this very interesting sample.

I would like to know if it is possible to use a Get instead of a Say, because it is easier for customers, but the same behaviour (if I press S, it should filter records contaning S, if I add SA, filter with SA...).

Re: possible with xBrowse?

Posted: Mon Aug 22, 2011 7:11 pm
by ukservice
Hello.

Is possible to use a Get?

Thank you.

Re: possible with xBrowse?

Posted: Thu Aug 25, 2011 10:43 am
by ukservice
Hello.

As I use a ribbon bar for add, delete, search, print, etc options, when a user clicks on it, focus is not on Say, or if the user press F1, say does not work.

That´s why I need Get, but it does not work, as ON CHANGE clause returns penultimate character, not last, so it does not work.

Any clue?.

Thank you.

Re: possible with xBrowse?

Posted: Mon Aug 29, 2011 11:27 am
by ukservice
Hello.

I would appreciate an answer.

Thank you very much.

Re: possible with xBrowse?

Posted: Mon Aug 29, 2011 11:33 am
by MdaSolution
On ribbon I use TSSAY class run ok
instead on ADD BUTTON SAYBUTTON it is not transparent

Re: possible with xBrowse?

Posted: Mon Aug 29, 2011 11:37 am
by MdaSolution
ukservice wrote:Hello.

Is possible to use a Get?

Thank you.

I think it can be possible only you must change also the

oSeek:SetText( cSeek )

I 'm thinking with
oSeek:cText( cSeek )
oSeek:REFRESH()

Re: possible with xBrowse?

Posted: Mon Aug 29, 2011 11:49 am
by MdaSolution
TRY IT HERE RUN OK

version with A get

Code: Select all

#include 'fivewin.ch'
#include 'ord.ch'
#include 'xbrowse.ch'
#include 'hbcompat.ch'

REQUEST DBFCDX

static cSeek   := ''
static oSeek

function Main()

   local oDlg, oBrw

   RDDSETDEFAULT( "DBFCDX" )
   USE CUSTOMER
   SET ORDER TO TAG FIRST
   GO TOP

   DEFINE DIALOG oDlg SIZE 600,400 PIXEL
   @ 30,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      AUTOCOLS ALIAS "CUSTOMER" CELL LINES NOBORDER

  * @ 10,10 SAY oSeek PROMPT cSeek SIZE 100,10 PIXEL ;
   *   OF oDlg COLOR CLR_BLACK,CLR_YELLOW

     @ 10,10 GET oSeek VAR cSeek SIZE 100,10 PIXEL ;
      OF oDlg COLOR CLR_BLACK,CLR_YELLOW

       oSeek:bKeyDown := { | nKey | KeyChar( oBrw, nKey ) }

   oBrw:bSeek  := nil   

   oBrw:bKeyChar  := { |nKey| KeyChar( oBrw, nKey ) }

   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED


return nil

static function KeyChar( oBrw, nKey )

   If nKey == VK_BACK .and. ! Empty( cSeek )
      ( oBrw:cAlias )->( IncrFilter( oBrw, Left( cSeek, Len( cSeek ) -1 ) ) )
      return 0
   elseIf nKey > 31
      ( oBrw:cAlias )->( IncrFilter( oBrw, cSeek + Chr( nKey ) ) )
      return 0
   Endif

return nil

static function IncrFilter( oBrw, cPattern )

   local cFilter, lFound := .f.
   local nRecNo, cSaveFilt, lStay

   if ValType( cPattern ) == 'C'
      if Empty( cPattern )
         cSeek       := ""
         * oSeek:SetText( cSeek )

         oSeek:cText( cSeek )
         oSeek:REFRESH()
         SET FILTER TO !DELETED()
         GO TOP
         oBrw:Refresh()
         lFound      := .t.
      else
         cFilter     := 'WildMatch( "*' + Upper(cPattern) + '*", UPPER( FIRST )) .AND. !DELETED()'
         cSaveFilt   := DBFILTER()
         nRecNo      := RECNO()
         lStay       := &cFilter
         SET FILTER TO &cFilter
         GO TOP
         if OrdKeyCount() == 0
            SET FILTER TO &cSaveFilt
            GO TOP
            DBGOTO( nRecNo )
         else
            cSeek    := cPattern
            oSeek:cText( cSeek )
         oSeek:REFRESH()

            if lStay
               DBGOTO( nRecNo )
               oBrw:Refresh()
            else
               oBrw:Refresh( .t. )
            endif
            lFound   := .t.
         endif
      endif
   endif

return lFound
 

Re: possible with xBrowse?

Posted: Tue Aug 30, 2011 3:09 pm
by ukservice
Mr. Mda,

Thank you but with get does not work.

Please try to type in the xbrowse area, then go to get and erase and type again.

Hope Mr. Rao checks it.