Thierry,
I have a problem with my grid. When I modify the recordSource (after a recordsource = ""), the title and controlsource of the columns are not preserved. The grid appears with all the cursor fields.
Hi Vincent, please post the corresponding code
Also, can you reproduce in desktop mode?
No problem in desktop mode. Here is my form with the grid:
Without refresh():
It's ok, except the dimensions of the columns ...
After refresh():
New fields and bad caption (signature)
Page1.Refresh_
DO CreatePartenaire
PROCEDURE CreatePartenaire
IF VARTYPE (Tabbord) = Cobjet
Tabbord.PageFrame1.Page1.Grid.RecordSource = Vierge
ENDIF
IF USED ("Cdossiers_p")
* Indispensable ?!
USE IN Cdossiers_p
ENDIF
SELECT Dossier, Dateacte, Prix, Vi.Infos, SUBSTR (Vi.numerodos, 5) AS Numero, Complet FROM Vi INNER JOIN Dossier ON Vi.Numerodos = Dossier.Numerodos INTO CURSOR Cdossiers_p READWRITE
ALTER TABLE Cdossiers_p ADD COLUMN Etat C(12)
REPLACE ALL Etat WITH ICASE (Complet = .T. .AND. .NOT. "xxx" $ Infos, "A signer !", Complet = .T., "Complet", "En cours ...") IN Cdossiers_p
GO TOP IN Cdossiers_p
IF VARTYPE (Tabbord) = Cobjet
Tabbord.PageFrame1.Page1.Grid.RecordSource = "Cdossiers_p"
ENDIF
RETURN
1/ Column width are exactly the same as in desktop
2/ How is the grid populated first time? Using the same procedure?
Are you sure that the initial cursor is also named "Cdossiers_p"?
3/ You can simplify your code:
procedure Page1.Refresh_
DO CreatePartenaire with this.Grid
PROCEDURE CreatePartenaire
lparameters oGrid
IF VARTYPE (m.oGrid) = Cobjet
m.oGrid.RecordSource = Vierge
ENDIF
USE IN select('Cdossiers_p') && works when used('Cdossiers_p') or not
SELECT;
Dossier;
, Dateacte;
, Prix;
, SUBSTR (Vi.numerodos, 5) AS Numero;
, cast(ICASE(Complet = .T. .AND. .NOT. "xxx" $ Vi.Infos, "A signer !", Complet = .T., "Complet", "En cours ...") as C(20)) as Etat;
FROM Vi INNER JOIN Dossier ON Vi.Numerodos = Dossier.Numerodos INTO CURSOR Cdossiers_p READWRITE
IF VARTYPE (m.oGrid) = Cobjet
m.oGrid.RecordSource = "Cdossiers_p"
ENDIF
RETURN
- Not for me
- Tabbord.load()
LOCAL abSelect
abSelect = abSelect()
IF .NOT. USED ("Cdossiers_p")
DO CreatePartenaire IN \VHDev\Appli\Dooxi\Dooxi.prg
ENDIF
IF .NOT. USED ("CVenacq")
CREATE CURSOR CVenacq (Lselection L, Partie C(254))
ENDIF
EOFset('Cdossiers_p')
RETURN DODEFAULT()
- Yes, thanks
1/ absolute columns widths are the same, they seem smaller in web mode because the grid is wider
you can add this code to expand the columns in Web mode
procedure xxxGrd.Init && or thisSpecificGrid.Init
if thisForm.wlWeb
local oGrc as Column
for each oGrc in this.columns foxobject
m.oGrc.width = m.oGrc.width * 1.5
endfor
endif
2/ Tabbord.PageFrame1.Page1.Grid
does not exist in Tabbord.Load()
You could just let page1.refresh()
execute naturally (after tabord.show()
) and populate the grid
Do you need "Cdossiers_p" somewhere else?
- I'll try
- I replaced the call to the procedure with a select ... into Cdossiers_p (this cursor is filled in the RecordSource of the Grid). The result is obviously identical. No, I do not need the cursor after.
- Question: with grids in FIC, rather than fill in a Column.ControlSource, is it better to systematically create a cursor whose structure includes only the fields to display and in their order of belonging in the grid ?
2/ what it you remove the call to CreatePartenaire
from .Load()
? Does it work better?
3/ no such limitation, you can define column.controlSource
at design time, should be kept at run time unless we have a bug in your specific case
- OK. Fine
- This have no effect. Same result. When i refresh my grid, its initial attributes are overwritten
do you have something in grid.recordSource_Assign()
?
wcRSCursor_Assign() ? No, just inherited code
Too fast, sorry.
Nothing in grid.recordSource_Assign()
could you try to move the code to another method than .refresh?()
Well seen. I put the call to the createpartenaire () in a button with a grid.refresh ().
On the click (), the grid is refreshing and does not modify its properties
Also OK in Activate()
I had this vague souvenir that changing .recordSource
in .refresh()
created issues
what is strange is that is does not behave the same in desktop mode
Hi Thierry,
You're right, the problem also exists in desktop mode. And also with activate().
The properties of the grid are not saved as soon as the data source is modified (even if initialized to "" previously).
I would set a breakpoint in recordSource_assign()
to see what's going on:
procedure recordSource_assign
lparameters tRecordSource
set step on
return doDefault(m.tRecordSource)