GRID RecNo() CellNavigation:=.F.

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
trmpluym
Posts: 303
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

GRID RecNo() CellNavigation:=.F.

Post by trmpluym »

Using a Grid with a DBF as source with CellNavigation:=.F. , how can i get the recno() ?

When I use the RecNo property it gives an array error.

See Grid demo 25, with only the line below changed.

Code: Select all

Form_1.Grid_1.CellNavigation := .F.
Attachments
GRID_25.zip
(1.47 MiB) Downloaded 220 times
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: GRID RecNo() CellNavigation:=.F.

Post by serge_girard »

Hi Theo,

I never use GRID + dbf so I cannot help on this one! Rathi perhaps?

Serge
There's nothing you can do that can't be done...
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: GRID RecNo() CellNavigation:=.F.

Post by mol »

I tried to use grid with .dbf files, but strange situasions happened.
I've abandoned this and I'm still using browse. It's quick and stable.
trmpluym
Posts: 303
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: GRID RecNo() CellNavigation:=.F.

Post by trmpluym »

Hi Serge, Marek,

Thanks for the reply's. So i understand nobody uses a grid with DBF files anymore ?

Theo
EduardoLuis
Posts: 682
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina

Re: GRID RecNo() CellNavigation:=.F.

Post by EduardoLuis »

Hi Trmpluym:

Not exactly.- Many of us uses GRID with dbf, and been honest works fine.-
By the way i don't use browse; in some cases i use GRID directly with tables, on others i use grid with arrays what it's to much high speed.-
I can't understand why you need to set CELLNAVIGATION := .F.
Perhaps you can get what you need by other ways.-
If you can explain more, we could think another solution.-
With regards.
Eduardo
jozef
Posts: 23
Joined: Sat Apr 02, 2016 4:53 pm
DBs Used: DBF
Location: Bratislava, Slovak Republic

Re: GRID RecNo() CellNavigation:=.F.

Post by jozef »

Hi,

i found in my old program with dbf and grid this rows:

go vkladaj.grid_1.CellRowFocused
old_row := vkladaj.grid_1.CellRowFocused

Maybe it will help you.
User avatar
gfilatov
Posts: 1060
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: GRID RecNo() CellNavigation:=.F.

Post by gfilatov »

trmpluym wrote: Tue Jan 16, 2018 8:39 pm Using a Grid with a DBF as source with CellNavigation:=.F. , how can i get the recno() ?

When I use the RecNo property it gives an array error.

See Grid demo 25, with only the line below changed.

Code: Select all

Form_1.Grid_1.CellNavigation := .F.
Hello,

Using a Grid with a DBF as source expects the CellNavigation mode for your Grid (default state).

But you can introduce the following modifications in the source h_grid.prg for support of a case when the CellNavigation mode is defined as false
and then recompile hmg library.

Code: Select all

************************************************
function SetDataGridRecNo ( index , nRecNo  )
************************************************
Local cRecordSource
Local aValue
Local nLogicalPos := 0
Local lOk := .f.
Local nBackRecNo
LOCAL nColumn := 0

   cRecordSource  := _HMG_SYSDATA [ 40 ] [ index ] [ 10 ]
   nBackRecNo     := &cRecordSource->( RECNO() )
   aValue         := _GetValue (  ,  ,  index )
   if ValType (aValue) == 'A'
      nColumn := aValue[2]
   endif

   if _IS_ACTIVE_FILTER_
      lOk := .f.
      nLogicalPos := 1
      &cRecordSource->( DBGOTOP() )

      Do While .Not. EOF()
         If &cRecordSource->( RECNO() ) == nRecNo
            lOk := .t.
//            nNewRecNo   := &cRecordSource->( RECNO() )   // ADD, march 2017
            Exit
         EndIf
         &cRecordSource->( DBSKIP() )
         nLogicalPos++
      EndDo
   else
      lOk := .t.
      &cRecordSource->( DBGOTO ( nRecNo ) )
      nLogicalPos := &cRecordSource->( ORDKEYNO () )
//      nNewRecNo   := &cRecordSource->( RECNO() )   // ADD, march 2017
   endif

   If lOk
//      &cRecordSource->( DBGOTO( nNewRecNo ) )   // ADD, march 2017
   else
      &cRecordSource->( DBGOTO( nBackRecNo ) )
   endif

   If lOk
      _SetValue (  ,  ,  if (ValType (aValue) == 'A', { nLogicalPos , nColumn } , nLogicalPos) , index )
   EndIf

return nil


*************************************
function GetDataGridRecno( index )
*************************************
Local cRecordSource := ''
Local nHandle
Local aColumnFields := {}
Local lRet := .T.
Local aValue
Local nValue
Local nRecNo
Local nBackRecNo

Local aTemp 
Local nBuffLogicalRow  
Local nBuffPhysicalRow 
Local k

   nHandle        := _HMG_SYSDATA [  3 ] [ index ] 
   aColumnFields  := _HMG_SYSDATA [ 40 ] [ index ] [ 11 ]
   cRecordSource  := _HMG_SYSDATA [ 40 ] [ index ] [ 10 ]
   nBackRecNo     := &cRecordSource->( RECNO() )
   aValue         := _GetValue (  ,  ,  index )
   nValue         := if ( ValType (aValue) == 'A', aValue[1], aValue )

   if _IS_ACTIVE_FILTER_
      &cRecordSource->( DBGOTOP() )
      &cRecordSource->( DBSKIP( nValue - 1 ) )
   else
      &cRecordSource->( ORDKEYGOTO ( nValue ) )
   endif
   
   If &cRecordSource->(EOF())
      nRecNo := 0
      // Try to get the buffer record number (if available)
      aTemp := _HMG_SYSDATA [ 40 ] [ index ] [21]
      For k := 1 To HMG_LEN ( aTemp )
         // Get Buffer Data
         nBuffLogicalRow  := aTemp [ k ] [ 1 ] 
         nBuffPhysicalRow := aTemp [ k ] [ 4 ] 
         If nBuffLogicalRow == _HMG_SYSDATA [ 39 ] [ index ]
            nRecNo := nBuffPhysicalRow
            Exit
         EndIf
      Next
   Else
      nRecNo := &cRecordSource->( RECNO() )
   EndIf

   &cRecordSource->( DBGOTO( nBackRecNo ) )

return nRecNo
In hope that helps :arrow:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
trmpluym
Posts: 303
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: GRID RecNo() CellNavigation:=.F.

Post by trmpluym »

Grigory,

You are a genius, just wat i was looking for :D

This is how it should work ! Your version should be included in the next version.

Many thanks for helping me out.

Theo
Post Reply