Cambios en xBrowse

Cambios en xBrowse

Postby acuellar » Tue Apr 14, 2015 9:17 pm

Antonio / Daniel

He realizado cambios en la función DolphinSeek del método SetDolphin porque no funcionaba correctamente.
Aquí los cambios
Code: Select all  Expand view

static FUNCTION DolphinSeek( c, oBrw, cQryWhere )

   local oQry        := oBrw:oMySql
   local nStart
   local uData, nNum, lRet
   local cSortOrder

   static aLastRec := {}

   if oBrw:lIncrFilter
     //  DEFAULT oBrw:cFilterFld := TOken( oQry:cOrder, , 1 )
         oBrw:cFilterFld := TOken( oQry:cOrder, , 1 )  //Le quite el DEFAULT porque no cambiaba orden al dar cllick en otra columna

      if Empty( oBrw:cFilterFld )
         return .f.
      endif

     // if Empty( c )
       If Len(c)=1 //Al usar BACK SPACE no colocaba el puntero en el primer registro
         c     := cQryWhere
      else
         c     := If( Empty( cQryWhere ), "", "(" + cQryWhere + ") and " ) + ;
                  Lower( oBrw:cFilterFld ) + " like '" + ;
                  If( oBrw:lSeekWild, "%", "" ) + ;
                  c + "%'"
      endif
      oQry:SetWhere( c, .t. )
      oQry:GoTop()
      return ( oQry:LastRec() > 0 )

   endif

   if Empty( c )
      return .t.
   endif

   nNum = AScan( oBrw:aCols, {| o | !Empty( o:cOrder ) } )

   if nNum < 1
      RETURN .f.
   endif

   cSortOrder = oBrw:aCols[ nNum ]:cSortOrder

   if Len( c ) == 1
      aLastRec    := {}
   endif

   IF Len( aLastRec ) < Len( c )
      IF Len( aLastRec ) == 0
         nStart = 1
      ELSE
         nStart = oQry:RecNo()
      ENDIF
      AAdd( aLastRec, nStart )
   ELSE
//      ADel( aLastRec, Len( aLastRec ) )
//      ASize( aLastRec, Len( aLastRec ) - 1 )
      ASize( aLastRec, Len( c ) - 1 )
      IF Len( aLastRec ) == 0
         nStart = 1
      ELSE
         nStart = ATail( aLastRec )
      ENDIF
   ENDIF

 //  lRet  := ( oQry:Seek( c, cSortOrder, nStart - 1, oQry:LastRec(), .T., .T. ) != 0 )
       lRet  := ( oQry:Seek( c, cSortOrder, nStart, oQry:LastRec(), .T., .T. ) != 0 ) //con el -1 al pulsar un caracter no nro. en orden numérico, se cuelga.

return lRet
 


Tengo FWH1501 no se si ya lo han corregido.



Code: Select all  Expand view

 @0,0 xBrowse oBrw Of oDlg AUTOSORT DATASOURCE oQry COLUMNS "IDEMPL" //Si no coloco COLUMNS me carga todos los campos
 //oBrw:setdolphin(oQry,.F.)  de esta manera no funciona la búsqueda
 oBrw....
 oBrw:lIncrFilter:= .t.
  oBrw:lSeekWild:= .t.

  oCol:=oBrw:AddCol()
   oCol:bEditValue  := { || oEMPL:CODIGO }
   oCol:nHeadStrAlign := AL_CENTER
   oCol:cHeader:= "COD."
   oCol:nWidth:=30
   oCol:cSortOrder := "CODIGO"
   oCol:bLClickHeader:= {|| oBrw:GoTop() }
   
   oCol:=oBrw:AddCol()
   oCol:bEditValue  := { || oEMPL:NOMBRE }
   oCol:nHeadStrAlign := AL_CENTER
   oCol:cHeader   := "NOMBRE Y APELLIDOS"
   oCol:nWidth:=223
   oCol:cSortOrder := "NOMBRE"
  oCol:bLClickHeader:= {|| oBrw:GoTop() }

   oBrw:aCols[1]:Hide() //Obligado a ocultarlo

  REDEFINE SAY oBrw:oSeek PROMPT oBrw:cSeek ID 114 OF oDlg UPDATE PICTURE "@!"

 


Existe otra manera de evitar el COLUMNS ó oBrw:setdolphin(oQry,.T.,.T.,{"IDEMPL"})

Saludos,

Adhemar
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1634
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia

Re: Cambios en xBrowse

Postby nageswaragunupudi » Wed Apr 15, 2015 8:42 am

Suggestion-1
Code: Select all  Expand view
    //  DEFAULT oBrw:cFilterFld := TOken( oQry:cOrder, , 1 )
         oBrw:cFilterFld := TOken( oQry:cOrder, , 1 )  //Le quite el DEFAULT porque no cambiaba orden al dar cllick en otra columna
 

We retain DEFAULT. This is intentional, not a mistake and is consistent with incremental filter behavior of all other sources like dbf, array, ado, etc.

Normally, cFilterFld is to be provided by the programmer initially. DEFAULT is provided in case of omission of this. It is intended that re-sorting of the data by the user should not disturb the filter.

If and when the programmer wants to change the filter field, he may do it by oBrw:Seek( "" ), oBrw:cFilterFld := <newfld>.

Suggestion-2
Code: Select all  Expand view
  // if Empty( c )
       If Len(c)=1 //Al usar BACK SPACE no colocaba el puntero en el primer registro
 

Please reconsider.
Our code "if Empty( c )" works properly.

Suggestion-3:
Code: Select all  Expand view
//  lRet  := ( oQry:Seek( c, cSortOrder, nStart - 1, oQry:LastRec(), .T., .T. ) != 0 )
       lRet  := ( oQry:Seek( c, cSortOrder, nStart, oQry:LastRec(), .T., .T. ) != 0 ) //con el -1 al pulsar un caracter
 


Original code by Mr Daniel was to use nStart only but not nStart-1. I saw his post sometime back that Mr Daniel prefers nStart but not nStart-1.

Years back we noticed that the the binary search logic of oQry:Seek was ignoring the first record (i.e, record number nstart). I did not see the recent sources of dolphin. As a result, oQry:Seek was returning false when only the 1st record was containing the search term.

Probably Max( 1, nStart - 1 ) is better.
Anyway we test this again and make necessary changes.
Regards

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

Re: Cambios en xBrowse

Postby acuellar » Wed Apr 15, 2015 12:20 pm

Thanks Mr. Rao

Regards,

Adhemar
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1634
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 130 guests