Incremental Search

Incremental Search

Postby Rick Lipkin » Fri Mar 02, 2012 10:48 pm

To All

I am trying to reproduce an old VB program that uses an incremental search in a Get field and displays the search in a listbox as the user types. I am using an Access recordset database.

On the surface this sounds like a daunting task because I there is only 'when' and 'valid' clause .. Here is a screen shot of the application I am trying to duplicate and second is the app I am in the process of creating.

Any help would be GREATLY appreciated !

Rick Lipkin

Old Program I am trying to duplicate
Image

New Program
Image
User avatar
Rick Lipkin
 
Posts: 2634
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Incremental Search

Postby reinaldocrespo » Sat Mar 03, 2012 4:46 pm

Hi Rick;

I think a simple solution would be to make the oGet where the Name is typed the oSeek property of the xbrowse:
Code: Select all  Expand view

oBrw:oSeek := oGet
 


That should work.



Reinaldo.
User avatar
reinaldocrespo
 
Posts: 972
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Incremental Search

Postby Rick Lipkin » Sat Mar 03, 2012 5:55 pm

Reinaldo

In reviewing the xBrowse source .. there is a ::cSeek variable .. are you suggesting something like this ? ::cSeek := oGet ??

If so how would you send that value as the user is typing ?

Thanks
Rick
User avatar
Rick Lipkin
 
Posts: 2634
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Incremental Search

Postby reinaldocrespo » Sat Mar 03, 2012 6:04 pm

Actually, I'm speaking of the oSeek property not the cSeek property. I guess it could also be done with the cSeek...?

Here is what I mean; let's say the get for the last name on the form looks like this:


Code: Select all  Expand view

   @ 1, 01 GET ::oSeek VAR ::cSearch OF oDlg SIZE 145, 35 UPDATE
 


Then on the xbrowse definition you would say:
Code: Select all  Expand view

      oBrw:oSeek      := ::oSeek
 


And you would have to worry about anything else. Of course you would need to have the dbf ordered by a key such that when the seek is executed it would move to the closest match. If xbrowsing an array, then make sure the array is sorted by the column containing the data being searched. I pretty sure that would work. Try it.


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 972
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Incremental Search

Postby Antonio Linares » Sat Mar 03, 2012 9:56 pm

Rick,

You have to use the ON CHANGE clause of the GET and perform a oBrw:Seek() of the written text:

Code: Select all  Expand view
#include "FiveWin.ch"
#include "xbrowse.ch"

function Main()

   local oDlg, cName := Space( 100 ), oBrw
   
   DEFINE DIALOG oDlg SIZE 400, 400
   
   @ 1, 5 GET cName SIZE 120, 12 ;
      ON CHANGE ( oBrw:GoDown(), MsgBeep() ) // oBrw:Seek( AllTrim( cName ) )
     
   @ 3, 1 XBROWSE oBrw ARRAY { "One", "Two", "Three", "Four", "Five" } OF oDlg ;
      SIZE 185, 150  
   
   oBrw:CreateFromCode()
   
   ACTIVATE DIALOG oDlg CENTERED

return nil


Replace oBrw:GoDown() with oBrw:Seek( AllTrim( cName ) ) for a DataBase
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41406
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Incremental Search

Postby Antonio Linares » Sat Mar 03, 2012 10:07 pm

Rick,

You have also a very good example at FWH\samples\xbincflt.prg though in that case the user types directly on the xbrowse
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41406
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Incremental Search

Postby Rick Lipkin » Sat Mar 03, 2012 11:01 pm

Antonio

Thank you for your suggestions .. what I was hoping to achieve here using an Access recordset was something like this:

Select * from Customer
oRs:Filter := "lname = 'bogus'" // gives me a eof recordset so the listbox is empty

Then as the user types I was hoping to modify the filter condition

cLname := "Smi"

oRs:Filter := ""
oRs:Filter := "lname like '"+cLname+"'%"

I will play with the ON CHANGE and maybe create a function that contains my filter updates .. Let me know what you think if I am on the right track.

Many Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2634
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Incremental Search

Postby Antonio Linares » Sun Mar 04, 2012 8:45 am

Rick,

Yes, it seems fine to me :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41406
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Incremental Search

Postby ukoenig » Sat Oct 06, 2012 9:58 pm

I wanted to include incremental seek on xBrowse, but doesn't work.
The say is empty nothing possible to type. Maybe because of using Resources ?

Image

REDEFINE XBROWSE oBrw ID 110 OF oFld:aDialogs[1] ;
COLUMNS "Number", "Name1", "Name2", "Notes" ;
FIELDS (5)->NUMBER, (5)->NAME1, (5)->NAME2, (5)->NOTES ;
FIELDSIZES 100, 100, 100 ,150 ;
HEADERS "Field 1", "Field 2", "Field 3", "Notes" ;
JUSTIFY .T., nil, .T., .T. // AUTOCOLS AUTOSORT

SetBrwStyle( oBrw )

// 1. Index
oBrw:aCols[1]:cSortOrder := "Number"
oBrw:aCols[1]:oHeaderFont:= oFont2
oBrw:aCols[1]:bClrHeader := {|| { 255,0 } }
oBrw:aCols[1]:AddResource( "B_Select" )
oBrw:aCols[1]:nHeadBmpNo := 1
oBrw:aCols[1]:bLClickHeader = { | nMRow, nMCol, nFlags, Self | ;
oBrw:aCols[1]:bClrHeader := {|| { 255,0 } }, ;
oBrw:aCols[3]:bClrHeader := {|| { 16711680,0 } }, ;
oBrw:Refresh() }
oBrw:aCols[1]:nHeadBmpAlign := AL_LEFT

oBrw:aCols[2]:oHeaderFont:= oFont2
oBrw:aCols[2]:bClrHeader := {|| { 0, } }

// 2. Index
oBrw:aCols[3]:cSortOrder := "NAME2"
oBrw:aCols[3]:oHeaderFont:= oFont2
oBrw:aCols[3]:bClrHeader := {|| { 16711680,0 } }
oBrw:aCols[3]:AddResource( "B_Select" )
oBrw:aCols[3]:nHeadBmpNo := 1
oBrw:aCols[3]:bLClickHeader = { | nMRow, nMCol, nFlags, Self | ;
oBrw:aCols[3]:bClrHeader := {|| { 255,0 } }, ;
oBrw:aCols[1]:bClrHeader := {|| { 16711680,0 } }, ;
oBrw:Refresh() }
oBrw:aCols[3]:nHeadBmpAlign := AL_LEFT

oBrw:aCols[4]:nEditType := EDIT_BUTTON
oBrw:aCols[4]:bEditBlock := { | r, c, o | EditNotes( r, c, o, EditData[10] ) }

oBrw:bLClicked := { | nRow, nCol | LOAD_FIEDS() }
oBrw:bChange := { || LOAD_FIEDS() }

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

REDEFINE SAY oBrw:oSeek PROMPT oBrw:cSeek ID 120 PIXEL ;
OF oFld:aDialogs[1] COLOR CLR_BLACK,CLR_YELLOW PICTURE '@!'


Best Regards
Uwe :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 40 guests