possible with xBrowse?

possible with xBrowse?

Postby mgsoft » Tue Aug 02, 2011 11:25 am

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 ;)
Saludos,

Eduardo
User avatar
mgsoft
 
Posts: 422
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

Re: possible with xBrowse?

Postby nageswaragunupudi » Thu Aug 04, 2011 6:30 pm

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  Expand view  RUN
#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.
Regards

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

Re: possible with xBrowse?

Postby mgsoft » Fri Aug 05, 2011 9:34 am

Thank you very much.

It works perfect.

xBrowse is too much powerfull!!!.
Saludos,

Eduardo
User avatar
mgsoft
 
Posts: 422
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

Re: possible with xBrowse?

Postby nageswaragunupudi » Fri Aug 05, 2011 10:44 am

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  Expand view  RUN
#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

//----------------------------------------------------------------------------//
 
Regards

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

Re: possible with xBrowse?

Postby mgsoft » Fri Aug 05, 2011 8:03 pm

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.
Saludos,

Eduardo
User avatar
mgsoft
 
Posts: 422
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

Re: possible with xBrowse?

Postby nageswaragunupudi » Sat Aug 06, 2011 2:34 am

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
Regards

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

Re: possible with xBrowse?

Postby mgsoft » Sat Aug 06, 2011 10:53 am

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.
Saludos,

Eduardo
User avatar
mgsoft
 
Posts: 422
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

Re: possible with xBrowse?

Postby ukservice » Fri Aug 19, 2011 7:57 am

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...).
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
User avatar
ukservice
 
Posts: 417
Joined: Tue Feb 23, 2010 3:09 pm
Location: John

Re: possible with xBrowse?

Postby ukservice » Mon Aug 22, 2011 7:11 pm

Hello.

Is possible to use a Get?

Thank you.
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
User avatar
ukservice
 
Posts: 417
Joined: Tue Feb 23, 2010 3:09 pm
Location: John

Re: possible with xBrowse?

Postby ukservice » Thu Aug 25, 2011 10:43 am

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.
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
User avatar
ukservice
 
Posts: 417
Joined: Tue Feb 23, 2010 3:09 pm
Location: John

Re: possible with xBrowse?

Postby ukservice » Mon Aug 29, 2011 11:27 am

Hello.

I would appreciate an answer.

Thank you very much.
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
User avatar
ukservice
 
Posts: 417
Joined: Tue Feb 23, 2010 3:09 pm
Location: John

Re: possible with xBrowse?

Postby MdaSolution » Mon Aug 29, 2011 11:33 am

On ribbon I use TSSAY class run ok
instead on ADD BUTTON SAYBUTTON it is not transparent
FWH .. BC582.. xharbour
User avatar
MdaSolution
 
Posts: 401
Joined: Tue Jan 05, 2010 2:33 pm

Re: possible with xBrowse?

Postby MdaSolution » Mon Aug 29, 2011 11:37 am

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()
Last edited by MdaSolution on Mon Aug 29, 2011 11:53 am, edited 1 time in total.
FWH .. BC582.. xharbour
User avatar
MdaSolution
 
Posts: 401
Joined: Tue Jan 05, 2010 2:33 pm

Re: possible with xBrowse?

Postby MdaSolution » Mon Aug 29, 2011 11:49 am

TRY IT HERE RUN OK

version with A get


Code: Select all  Expand view  RUN
#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
 
FWH .. BC582.. xharbour
User avatar
MdaSolution
 
Posts: 401
Joined: Tue Jan 05, 2010 2:33 pm

Re: possible with xBrowse?

Postby ukservice » Tue Aug 30, 2011 3:09 pm

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.
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
User avatar
ukservice
 
Posts: 417
Joined: Tue Feb 23, 2010 3:09 pm
Location: John

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 67 guests