I have a grid with 3 columns. The first has enabled = .F., the others have enabled = .T. In the second column i have a checkbox and in the third there is the standard textbox. The controlsource of the second column is a logical field, the third i is a numeric field.... The grid.recordsource is set after a query, at runtime. Immediately after the data in the grid are shown, the third columns shows the correct data, but the alignment seems uncorrect and in fact data shown are correct but trey are as character and not numeric values...and if i modify these data i can insert also character values. If is suspend the execution i can see that the controlsource is correct and that the cursor structure is correct.... Obviously if i save data all i have edited in the third column is not saved....
Can you query the cursor nodata
in form.load()
and assign .RecordSource = 'YourNodataCursor'
at design time or in grid.init()
? (and assign .RecordSource = ''
before querying it again)
This way FoxInCloud will know the column types at initial HTML generation.
Should be more simple than trying to tackle this at runtime.
Created the cursor in form.load() and at design time assigned grid.recordsource and controlsource for all column..... Unmodified my query that make a new sql and assign again all grid's property and before querying set grid.recordsource = ""
Nothing changes... The column is still character even if linked to a numeric field in cursor...
I saw that even before making the second query the grid is already wrong..
Ciao Michele,
We discussed a similar issue in 2014…
What is
type(column.controlSource)
column.InputMask
column.Format
?
If your column is Numeric, how can you have a 'a' on the 'MANUTENZIONE' line?
Here are data you requested.... This issue has been opened because i can insert "A" in that column...
The particular thing is that if i insert manually data in the numeric fields directly in the table when i open this form i can see the data inserted but in a column where i can insert also characters values...
i'm still using 2.26.2
With 2.27.0b5 no changes.
I solved the problem if i use in the column a custom textbox class instead of standard text1... I can edit numbers and save them..apparently i can also edit characters values but when i confirm it i see 0...
OK I see thanks
Please post the JavaScript code generated just for this column like in this example (from form.js
):
/* Column 8 'Column9' *//
oTempl = oGrid.getHeaderTemplate(8);
oTempl.setStyle('text-align','center');
/* -- Text1 (Textbox) -- *//
oTempl = oGrid.getCellTemplate(8);
oTempl.setStyle('text-align','right');
Here is the new code, with my stdtext class instead of standard..
/* Column 2 'Column3' */
oTempl = oGrid.getHeaderTemplate(2);
oTempl.setStyle('text-align','center');
oTempl.setStyle('font-size','13pt');
oGrid.setCellTemplate('',2,undefined);
oGrid.setCellCurrentControl('_textbox_numeric1', 2);
oTempl = oGrid.getCellTemplate(2);
oTempl.setStyle('text-align','left');
oTempl.setStyle('font-size','12pt');
Here is the code that doesn't work
/* Column 2 'Column3' */
oTempl = oGrid.getHeaderTemplate(2);
oTempl.setStyle('text-align','center');
oTempl.setStyle('font-size','13pt');
oGrid.setCellTemplate('',2,undefined);
oGrid.setCellCurrentControl('text1', 2);
oTempl = oGrid.getCellTemplate(2);
oTempl.setStyle('text-align','left');
oTempl.setStyle('font-size','12pt');
oTempl.setStyle('font-size','13pt');
Well, both code have oTempl.setStyle('text-align','left');
and none has var fmt = new AW.Formats.Number;
that sets the column as Numeric.
Can't see any reason why code 1 works better than 2
Can you send the full <form>.js
code to support at foxincloud dot com or provide an on-line repro case?
Thanks in advance
I sent the files.... This version is not in an online server..
Got the JS code thanks… still no clue to understand 😕
Could you post the full form code (you can get it using the class browser)?
**************************************************
*-- Class: _form_bollettino_checklist (h:\cloud\erpmobile\mobile.vcx)
*-- ParentClass: _form (h:\cloud\erpmobile\mobile.vcx)
*-- BaseClass: form
*-- Time Stamp: 06/21/18 10:04:01 AM
*
DEFINE CLASS _form_bollettino_checklist AS _form
Top = 0
Left = 0
Height = 407
Width = 1007
DoCreate = .T.
ido = 0
custom_wcpropsave = "ido"
Name = "_form_bollettino_checklist"
waitpic.Height = 20
waitpic.Width = 20
waitpic.Name = "waitpic"
ADD OBJECT grid1 AS _grid WITH ;
ColumnCount = 3, ;
FontName = "Verdana", ;
FontSize = 13, ;
Height = 325, ;
Left = 12, ;
Panel = 1, ;
RecordMark = .F., ;
RowHeight = 23, ;
ScrollBars = 2, ;
Top = 72, ;
Width = 660, ;
Name = "Grid1", ;
Column1.FontName = "Verdana", ;
Column1.FontSize = 12, ;
Column1.ControlSource = "", ;
Column1.Width = 429, ;
Column1.ReadOnly = .T., ;
Column1.Name = "Column1", ;
Column2.FontName = "Verdana", ;
Column2.FontSize = 13, ;
Column2.ColumnOrder = 3, ;
Column2.ControlSource = "", ;
Column2.CurrentControl = "_checkbox1", ;
Column2.Width = 36, ;
Column2.Sparse = .F., ;
Column2.Name = "Column2", ;
Column3.FontName = "Verdana", ;
Column3.FontSize = 12, ;
Column3.ColumnOrder = 2, ;
Column3.ControlSource = "", ;
Column3.CurrentControl = "_textbox_numeric1", ;
Column3.Width = 123, ;
Column3.Sparse = .F., ;
Column3.Format = "Z", ;
Column3.Name = "Column3"
ADD OBJECT _form_bollettino_checklist.grid1.column1.header1 AS header WITH ;
FontName = "Verdana", ;
FontSize = 13, ;
Alignment = 2, ;
Caption = "Descrizione", ;
Name = "Header1"
ADD OBJECT _form_bollettino_checklist.grid1.column1.text1 AS textbox WITH ;
FontName = "Verdana", ;
FontSize = 12, ;
BorderStyle = 0, ;
Enabled = .T., ;
Margin = 0, ;
ReadOnly = .T., ;
ForeColor = RGB(0,0,0), ;
BackColor = RGB(255,255,255), ;
Name = "Text1"
ADD OBJECT _form_bollettino_checklist.grid1.column2.header1 AS header WITH ;
FontName = "Verdana", ;
FontSize = 13, ;
Alignment = 2, ;
Caption = "S", ;
Name = "Header1"
ADD OBJECT _form_bollettino_checklist.grid1.column2.text1 AS textbox WITH ;
FontName = "Verdana", ;
FontSize = 13, ;
BorderStyle = 0, ;
Margin = 0, ;
ForeColor = RGB(0,0,0), ;
BackColor = RGB(255,255,255), ;
Name = "Text1"
ADD OBJECT _form_bollettino_checklist.grid1.column2._checkbox1 AS _checkbox WITH ;
Top = 35, ;
Left = 23, ;
FontName = "Verdana", ;
FontSize = 13, ;
Alignment = 0, ;
Caption = "", ;
Name = "_checkbox1"
ADD OBJECT _form_bollettino_checklist.grid1.column3.header1 AS header WITH ;
FontName = "Verdana", ;
FontSize = 13, ;
Alignment = 2, ;
Caption = "Valore", ;
Name = "Header1"
ADD OBJECT _form_bollettino_checklist.grid1.column3.text1 AS textbox WITH ;
FontName = "Verdana", ;
FontSize = 13, ;
Alignment = 3, ;
BorderStyle = 0, ;
Value = 0, ;
Margin = 0, ;
ForeColor = RGB(0,0,0), ;
BackColor = RGB(255,255,255), ;
Name = "Text1"
ADD OBJECT _form_bollettino_checklist.grid1.column3._textbox_numeric1 AS _textbox_numeric WITH ;
FontSize = 12, ;
Left = 73, ;
Top = 47, ;
Name = "_textbox_numeric1"
ADD OBJECT _commandbutton_close1 AS _commandbutton_close WITH ;
Top = 12, ;
Left = 12, ;
Width = 50, ;
TabStop = .F., ;
SpecialEffect = 2, ;
ZOrderSet = 9, ;
Name = "_commandbutton_close1"
ADD OBJECT _editbox1 AS _editbox WITH ;
Enabled = .F., ;
Height = 324, ;
Left = 676, ;
Top = 72, ;
Width = 324, ;
DisabledForeColor = RGB(0,0,0), ;
Name = "_editbox1"
ADD OBJECT _commandbutton5 AS _commandbutton WITH ;
Top = 12, ;
Left = 72, ;
Picture = "..\..\graphics\icons\png\32x32\6\save.32_6.png", ;
Caption = "", ;
TabStop = .F., ;
SpecialEffect = 2, ;
ZOrderSet = 6, ;
Name = "_commandbutton5"
ADD OBJECT _commandbutton1 AS _commandbutton WITH ;
Top = 12, ;
Left = 132, ;
Picture = "..\..\graphics\icons\png\32x32\6\refresh.32_6.png", ;
Caption = "", ;
TabStop = .F., ;
SpecialEffect = 2, ;
ZOrderSet = 6, ;
Name = "_commandbutton1"
PROCEDURE runquery
Local nIdo
nIdo = This.Ido
This.Grid1.RecordSource = ""
=Use("Clt")
=Use("Clr")
=Use("Arts")
=Use("TaGen")
Select Idt From Clt Where Ido = nIdo Into Array aIdt
If _Tally = 0
Insert Into Clt (Ido) Values (nIdo)
Select * From Arts Where Empty(Cat) And Empty(Cod) Into Cursor tArts
Do While !Eof("tArts")
Insert Into Clr (Idt, Seq, Cfa, Mn1) Values (Clt->Idt, tArts->Seq, tArts->Cfa, tArts->Mn1)
Skip In tArts
EndDo
Use In tArts
nIdt = Clt->Idt
Else
nIdt = aIdt[1,1]
Endif
Select Clr->*, TaGen->Des1 ;
From Clr ;
Left Outer Join TaGen On TaGen->Code = Clr->Cfa And TaGen->Tipo = "LC";
Where Idt = nIdt ;
Order By Seq ;
Into Cursor Clist ReadWrite
*!*Index On Id Tag Id Candidate
Use In Clt
Use In Clr
Use In Arts
Use In TaGen
With This.Grid1
.RecordSource = "Clist"
*!*.wcPKexpr = "id"
.Column1.ControlSource = "Clist->Des1"
.Column2.ControlSource = "Clist->Fl1"
If Type("Clist->Vnu") = "Y"
.Column3.ControlSource = "Clist->Vnu"
Else
.Column3.ControlSource = ""
.Column3.Visible = .F.
Endif
*!*.SetFocus()
EndWith
ENDPROC
PROCEDURE Init
Lparameters cUser, nIdo
If Pcount() > 0
DoDefault()
With This
.User = cUser
.Ido = nIdo
.runQuery()
EndWith
Endif
ENDPROC
PROCEDURE Load
DoDefault()
*!* =Use("Clr")
*!* =Use("TaGen")
*!* Select Clr->*, TaGen->Des1 ;
*!* From Clr ;
*!* Left Outer Join TaGen On TaGen->Code = Clr->Cfa And TaGen->Tipo = "LC";
*!* Where .F.;
*!* Order By Seq ;
*!* Into Cursor Clist ReadWrite
*!* Use In Clr
*!* Use In TaGen
ENDPROC
PROCEDURE grid1.wafterrowchange
LPARAMETERS tuRow && see documentation in awGrd.wAfterRowChange()
If Used("Clist") And Type("tuRow") != "L"
Go tuRow In Clist
*!*=Seek(tuRow,"Clist","Id")
ThisForm._Editbox1.Value = Clist->Mn1
ThisForm._Editbox1.Refresh()
Endif
ENDPROC
PROCEDURE _textbox_numeric1.Valid
lparameters uselessParm && {en} doc in Parent Code {fr} doc dans le code parent
If (Type('m.thisForm.wlHTMLgen') == 'L' And m.thisForm.wlHTMLgen)
Return .T.
Else
Replace Fl1 With (This.Value != 0) In Clist
Endif
ENDPROC
PROCEDURE _commandbutton5.buttonclick
=Use("Clr")
Go Top In Clist
Do While !Eof("Clist")
If Type("Clist->Vnu") = "Y"
Update Clr Set Fl1 = Clist->Fl1, Vnu = Clist->Vnu, Dt1 = Datetime() Where Id = Clist->Id
Else
Update Clr Set Fl1 = Clist->Fl1, Dt1 = Datetime() Where Id = Clist->Id
Endif
Skip In Clist
EndDo
Use In Clr
Go Top In Clist
ThisForm.Release
ENDPROC
PROCEDURE _commandbutton1.buttonclick
Local nIdo
nIdo = ThisForm.Ido
=Use("Clt")
=Use("Clr")
Select Idt From Clt Where Ido=nIdo Into Array aIdt
If _Tally > 0
nIdt = aIdt[1,1]
Delete From Clt Where Idt = nIdt
Delete From Clr Where Idt = nIdt
Endif
Use In Clt
Use In Clr
ThisForm.runQuery()
ENDPROC
ENDDEFINE
*
*-- EndDefine: _form_bollettino_checklist
**************************************************
grid1.recordSource
and grid1.Columns.controlSource
should be set to Clist.*
initially
you can:
- add a
noData as Boolean
parameter to yourrunQuery
Method, adapt code to run withnoData
- in
form.load()
, callthisForm.runQuery(.T.)
to create the cursornodata
- in grid1.Init(), call
thisForm.runQuery()