FoxInCloud
Grid - wAfterRowChange
Gravatar is a globally recognized avatar based on your email address. Grid - wAfterRowChange
  Vincent H.
  All
  Feb 15, 2020 @ 09:40am

Hi Thierry,

In some cases, the line change in a grid does not cause movement in the recordsource.
In my example below, the source is an unindexed cursor.
I have to do a GO TO to position myself in the table.

Note: in my example, the 1st field of the table is numeric.
What did I not understand?

LPARAMETERS tuRow && see documentation in awGrd.wAfterRowChange()
IF (Type('m.thisForm.wlHTMLgen') == 'L' AND m.thisForm.wlHTMLgen)
   RETURN .T.
ENDIF
IF !DoDefault(@m.tuRow)
   RETURN
ENDIF
GO tuRow IN (THIS.RecordSource)   && otherwise, I stay on the 1st recording
Mycontrol.Refresh
Gravatar is a globally recognized avatar based on your email address. re: Grid - wAfterRowChange
  Vincent H.
  Vincent H.
  Feb 15, 2020 @ 10:06am

In my grid class, should I add this in wAfterRowChange()

IF RECNO (THIS.RecordSource) # tuRow
   GO tuRow IN (THIS.RecordSource)
ENDIF

Thanks in advance

Gravatar is a globally recognized avatar based on your email address. re: Grid - wAfterRowChange
  FoxInCloud Support - Thierry N.
  Vincent H.
  Feb 17, 2020 @ 03:07am

Hi Vincent,

If awGrd.wRowChange() does not find a unique key (primary or candidate), it interprets tuRow as a record number and attempts to set it as recno(). If it fails, it returns .F., and dodefault(@m.tuRow) also returns .F., so your GO instruction does not execute.

I never heard of an issue here and am unable to reproduce it, so if you have a doubt and prefer set recno() yourself, it's OK with me.

Gravatar is a globally recognized avatar based on your email address. re: Grid - wAfterRowChange
  Vincent H.
  FoxInCloud Support - Thierry N.
  Feb 17, 2020 @ 06:14am

Thank you for your answer.
That's what I understood but I confirm that in my case I had to add a GO tuRow
Like you write, this statement should not be interpreted if DoDefault(@m.tuRow) returns .F.
The form is called RegisterM.scx

© 1996-2024