Búsqueda incremental en RecordSet
Posted:
Tue Feb 19, 2013 8:40 pm
by Pedro
Hola a todos
Me gustaría que me tiráseis una manita con el siguiente código que os pongo. Es una búsqueda incremental en un RecordSet y, la búsqueda la hace bien,
peeeeeeeeeeeeeroooooooo, no doy con la forma de ver que estoy escribiendo, no me pinta nada en el SAY oTexto.
¿Me podéis decir que hago mal, para que no me pinte lo que tecleo?
- Code: Select all Expand view
DEFINE DIALOG oDlgBus RESOURCE "BUSCARCLIE" COLOR RGB(0,0,0),RGB(153,204,153)
oBrwCli := TXBrowse():New( oDlgBus )
oBrwCli:bSeek := { |c| BuscaIncr( oRsClie,c,"Nombre",oDlgBus) }
oBrwCli:oSeek := oTexto
oBrwCli:SetAdo(oRsClie,.T.,.T.)
oBrwCli:nMarqueeStyle := MARQSTYLE_HIGHLCELL
oBrwCli:nColDividerStyle := LINESTYLE_BLACK
oBrwCli:nRowDividerStyle := LINESTYLE_BLACK
oBrwCli:lColDividerComplete := .t.
for nFor := 1 to len( oBrwCli:aCols )
oCol := oBrwCli:aCols[ nFor ]
oCol:nEditType := 0
next
oBrwCli:aCols[1]:nWidth := 60
oBrwCli:aCols[2]:nWidth := 500
oBrwCli:CreateFromResource(2001)
REDEFINE SAY cTexto ID 4001 OF oDlgBus ;
COLOR RGB(0,0,0),RGB(153,204,153)
REDEFINE SAY oTexto Var cNombre ID 4002 PICTURE "@!" of oDlgBus UPDATE;
COLOR RGB(0,0,0),RGB(204,204,102)
......
botones y Activar el dialogo
La Función BuscaIncr es la que se encarga de hacer la búsqueda, si hay alguna forma de hacerlo mejor, soy todo ojos....
Re: Búsqueda incremental en RecordSet
Posted:
Tue Feb 19, 2013 8:54 pm
by Bayron
Yo lo utilizo con una Base de Datos, y lo hago incluyendo la siguiente linea:
- Code: Select all Expand view
oBrwCli:bUpdateBuffer := {|| oSay:Refresh() }
Re: Búsqueda incremental en RecordSet
Posted:
Wed Feb 20, 2013 9:27 am
by Pedro
Hola Byron
No funciona, lo único que hace es crearme una columna al final con el nombre de bUpdateBuffer.
Lo que si he visto es que mi función de bSeek ni hace absolutamente nada, es decir no va a ella cuando inicio el tecleo de búsqueda.
También he visto que la data oSeek solo se emplea en el método Seek, pero no en los métodos de búsqueda de ADO, TMYSQL o DOLPHIN,
por lo cual será imposible que veamos lo que escribimos.
Dado que uso el fuente de la clase xBrowse en mi programa, trataré de modificarla en el método AdoSeek (ver 12.04) y AdoIncrSeek (ver 12.06)
para intentar ver lo que escribo
Re: Búsqueda incremental en RecordSet
Posted:
Sun Feb 24, 2013 3:31 pm
by nageswaragunupudi
This sample demonstrates using incremental seek and wild seek in FWH 12.06 using ADO RecordSets. XBrowse works perfectly and advise not to make any changes to the library.
- Code: Select all Expand view
#include "FiveWin.Ch"
#include "xbrowse.ch"
#include "hbcompat.ch"
//----------------------------------------------------------------------------//
Function Main()
local oRs, oDlg, oBrw, oCbx, oFont
local lWildSeek := .f.
local nOpt := 1
oRs := GetRecSet()
oRs:Sort := oRs:Fields( 0 ):Name
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE DIALOG oDlg SIZE 900,400 PIXEL ;
TITLE FWVERSION ;
FONT oFont
@ 30,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
DATASOURCE oRs AUTOCOLS AUTOSORT ;
CELL LINES NOBORDER
WITH OBJECT oBrw
:Married:SetCheck()
:bClrSel := { || { CLR_BLACK,CLR_HGRAY } }
:nStretchCol := STRETCHCOL_WIDEST
//
:CreateFromCode()
END
@ 10,10 COMBOBOX nOpt PROMPTS { "Starting With", "Containing" } ;
SIZE 60,14 PIXEL OF oDlg ;
ON CHANGE ( oBrw:lSeekWild := ( nOpt == 2 ), ;
oBrw:Refresh(), oBrw:SetFocus() )
@ 10, 80 SAY oBrw:oSeek PROMPT oBrw:cSeek SIZE 80,10 PIXEL OF oDlg ;
COLOR CLR_RED,CLR_YELLOW
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT ( oBrw:SetFocus(), .f. )
RELEASE FONT oFont
oRs:Close()
oRs:ActiveConnection:Close()
Return nil
//----------------------------------------------------------------------------//
static function GetRecSet()
local oRs, oCn
local cStr := "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ;
"c:\fwh\samples\;Extended Properties=dBASE III;" + ;
"User ID=Admin;Password=;"
if ( oCn := FW_OpenAdoConnection( cStr ) ) == nil
MsgStop( "Connection Fail" )
QUIT
elseif ( oRs := FW_OpenRecordSet( oCn, ;
"SELECT FIRST,CITY,MARRIED,HIREDATE,SALARY FROM CUSTOMERS" ) ) == nil
MsgStop( "CUSTOMERS can not be opened" )
oCn:Close()
QUIT
endif
return oRs
//----------------------------------------------------------------------------//
This sample also shows how to show the Search String.
Note: For the purpose of the above sample, I have opened c:\fwh\samples\cutomer.dbf as a RecordSet using ADO ( using Jet OLEDB ). If your fwh folder is not in c:, please change the address in the above sample to point to your fwh\samples folder.
Please compile and test the above sample, before asking further clarifications.
Screen Shots:
Incremental Seek:
Wild Seek:
Re: Búsqueda incremental en RecordSet
Posted:
Tue Feb 26, 2013 2:57 pm
by jbrita
Amigo prueba asi:
Local nIndex:={"ma_rutc","ma_nomc"}
REDEFINE COMBOBOX oCbx VAR cVar ITEMS aIdx ID 1007 OF oDlg UPDATE;
ON CHANGE SeOrden(oCbx,oLbx,nIndex)
REDEFINE SAY oSay ID 101 OF oDlg UPDATE FONT oVentPrinc:oFont COLOR CLR_BLUE
oLbx:SetAdo(cMa_Ctes)
oLbx:bSeek := {|c| BBus(c,cMa_Ctes,nIndex[cVar]) }
oLbx:oSeek := oSay
oLbx:bKeyDown := {|nKey| iif( nKey=13,(cKey := ADOField(cMa_Ctes,"ma_rutc"),oDlg:End() ),)}
STATIC FUNCTION BBus(cBuscar,oRs,oOrden)
Local nLen:=Len(cBuscar)
static nLenAnt
Default nLenAnt:=0
If Len(cBuscar) > 1
If (nLenAnt>nLen,oRs:MoveFirst(),)
oRs:Find(oOrden+" Like '"+UPPER(cbuscar)+"*'",,1)
Else
oRs:MoveFirst()
If !Empty(cBuscar)
oRs:Find(oOrden+" Like '"+UPPER(cbuscar)+"*'",,1)
Endif
Endif
nLenAnt:=nLen
RETURN !(oRs:Eof .or. oRs:Bof)
Saludos
Re: Búsqueda incremental en RecordSet
Posted:
Tue Feb 26, 2013 5:35 pm
by Pedro
Estimado jbrita, como ya dije en otro post , el problema del bSeek es que no me toma el que yo hago, sino el de la clase.
No se que versión de FWH estas usando pero con la 12.06 no puedo hacer lo que me dices porque nunca va a ir a la funcion BBus(), lo digo porque ya hice una función igual a la que has puesto y jamás llegaba a esa función, (puse unos msginfo para ver si llegaba y nada, no iba). Creo que la explicación la dio mister Nao en el post que te digo
http://forums.fivetechsupport.com/viewtopic.php?f=6&t=25686