FoxInCloud
Grid <-> Textbox
Gravatar is a globally recognized avatar based on your email address. Grid <-> Textbox
  Vincent H.
  All
  Oct 9, 2019 @ 10:43am

Good evening thierry,
I'm trying to develop an inter-action between a grid and a textbox. The controlSource of the textbox is dynamically assigned with wAfterColChange () like this:

IF (Type('m.thisForm.wlHTMLgen') == 'L' AND m.thisForm.wlHTMLgen)
   RETURN .T.
ENDIF
IF !DoDefault(@m.nColIndex)
   return
ENDIF
WITH THIS.Parent.Saisie
   .ControlSource = THIS.Columns(@m.nColIndex).ControlSource
   .SetFocus
ENDWITH
DODEFAULT()

The entered value (in textbox) does not automatically refer to update the grid.
How to proceed ?
Thank you in advance ...

Gravatar is a globally recognized avatar based on your email address. re: Grid <-> Textbox
  Gilles Lajot-Sarthou
  Vincent H.
  Oct 9, 2019 @ 10:30pm

Bonjour Vincent, Did you try to use a grid.refresh() in the saisie.valid() ?

Cordialement

Gravatar is a globally recognized avatar based on your email address. re: Grid <-> Textbox
  Vincent H.
  Gilles Lajot-Sarthou
  Oct 10, 2019 @ 12:31am

Hello Gilles,

Thanks, yes and also change the value directly in the grid control.
No effect, the cursor is updated at output and overwrites this value.

Gravatar is a globally recognized avatar based on your email address. re: Grid <-> Textbox
  FoxInCloud Support - Thierry N.
  Vincent H.
  Oct 10, 2019 @ 02:09am

.controlSource updates after .Valid() returns a non-empty value such as the default .T.. Difficult to control in which order .controlSource update and .refresh() act.

I would rather use a custom property:

procedure saisie.Init
…
this.addproperty('nColIndex', -1)
return dodefault()

procedure grid.wAfterColChange

IF (Type('m.thisForm.wlHTMLgen') == 'L' AND m.thisForm.wlHTMLgen)
   RETURN .T.
ENDIF
IF !DoDefault(@m.nColIndex)
   return .F.
ENDIF
WITH THIS.Parent.Saisie
   .nColIndex = m.nColIndex
   .Value = evaluate(THIS.Columns(m.nColIndex).ControlSource)
   .Refresh
   .SetFocus
ENDWITH

procedure saisie.Valid

replace in (THIS.Parent.Grid.rowSource) (THIS.Parent.Grid.Columns(this.nColIndex).ControlSource) with this.Value

THIS.Parent.Grid.Columns(this.nColIndex).Refresh
Gravatar is a globally recognized avatar based on your email address. re: Grid <-> Textbox
  Vincent H.
  FoxInCloud Support - Thierry N.
  Oct 10, 2019 @ 03:13am

Thanks Thierry, it's works fine !

Just a correction:

REPLACE ... IN (THIS.Parent.Grid.RecordSource)   && not RowSource

I think this can be useful when the grid has a lot of columns, like the example below:

Gravatar is a globally recognized avatar based on your email address. re: Grid <-> Textbox
  FoxInCloud Support - Thierry N.
  Vincent H.
  Oct 10, 2019 @ 03:25am

.RecordSource && not .RowSource

sure

© 1996-2019