GRID RecNo() CellNavigation:=.F.

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
trmpluym
Posts: 216
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands
Has thanked: 5 times
Been thanked: 15 times

GRID RecNo() CellNavigation:=.F.

Post by trmpluym » 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.
Attachments
GRID_25.zip
(1.47 MiB) Downloaded 19 times

User avatar
serge_girard
Posts: 1959
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 346 times
Been thanked: 78 times
Contact:

Post by serge_girard » Wed Jan 17, 2018 4:57 pm

Hi Theo,

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

Serge

User avatar
mol
Posts: 2910
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 149 times
Been thanked: 82 times
Contact:

Post by mol » Wed Jan 17, 2018 7:35 pm

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: 216
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands
Has thanked: 5 times
Been thanked: 15 times

Post by trmpluym » Thu Jan 18, 2018 10:12 am

Hi Serge, Marek,

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

Theo

EduardoLuis
Posts: 528
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina
Been thanked: 30 times

Post by EduardoLuis » Thu Jan 18, 2018 12:43 pm

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: 19
Joined: Sat Apr 02, 2016 4:53 pm
DBs Used: DBF
Location: Bratislava, Slovak Republic
Has thanked: 8 times
Been thanked: 1 time

Post by jozef » Thu Jan 18, 2018 5:32 pm

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: 529
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Has thanked: 8 times
Been thanked: 97 times
Contact:

Post by gfilatov » Thu Jan 18, 2018 8:25 pm

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: 216
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands
Has thanked: 5 times
Been thanked: 15 times

Post by trmpluym » Thu Jan 18, 2018 10:14 pm

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