Page 1 of 1
GRID RecNo() CellNavigation:=.F.
Posted: Tue Jan 16, 2018 8:39 pm
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.
Re: GRID RecNo() CellNavigation:=.F.
Posted: Wed Jan 17, 2018 4:57 pm
by serge_girard
Hi Theo,
I never use GRID + dbf so I cannot help on this one! Rathi perhaps?
Serge
Re: GRID RecNo() CellNavigation:=.F.
Posted: Wed Jan 17, 2018 7:35 pm
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.
Re: GRID RecNo() CellNavigation:=.F.
Posted: Thu Jan 18, 2018 10:12 am
by trmpluym
Hi Serge, Marek,
Thanks for the reply's. So i understand nobody uses a grid with DBF files anymore ?
Theo
Re: GRID RecNo() CellNavigation:=.F.
Posted: Thu Jan 18, 2018 12:43 pm
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
Re: GRID RecNo() CellNavigation:=.F.
Posted: Thu Jan 18, 2018 5:32 pm
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.
Re: GRID RecNo() CellNavigation:=.F.
Posted: Thu Jan 18, 2018 8:25 pm
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
Re: GRID RecNo() CellNavigation:=.F.
Posted: Thu Jan 18, 2018 10:14 pm
by trmpluym
Grigory,
You are a genius, just wat i was looking for
This is how it should work ! Your version should be included in the next version.
Many thanks for helping me out.
Theo