Jun 27, 2015, 10:47 PM
[CLOSED] DateField and parsing problems
Hi, in two different projects I'm experiencing a parsing error of date in a DateField.
Sadly I'm not able to create a demo because in demo this works, but I tried to go deep inside and maybe I found something that it could be useful for you.
The scenario is:
Once the data has been loaded anything has correctly rendered. When I click the DateField the editor does not show the date, like the date were null.
In that project I'm able to add rows in run-time and this behavior does not occur with that rows.
I tried to find differences between the demo (witch works) and both projects and I found that the data in the following function is different.
The function is after this call:
in working project, value is Sat Jun 27 2015 00:00:00 GMT+0200 (ora legale Europa occidentale)
it seems that altFormats does not have a format for xml date.
Demo page is this one:
Have I been able to give you enough info in order you to help me?
Thank you, I know that until it works it is difficult to fix... it is complicated to include the whole project.
I'll carry on investigating.
Sadly I'm not able to create a demo because in demo this works, but I tried to go deep inside and maybe I found something that it could be useful for you.
The scenario is:
- GridPanel
- DataColumn with a DateField as editor
- DataSet.DataTable as store
Once the data has been loaded anything has correctly rendered. When I click the DateField the editor does not show the date, like the date were null.
In that project I'm able to add rows in run-time and this behavior does not occur with that rows.
I tried to find differences between the demo (witch works) and both projects and I found that the data in the following function is different.
The function is after this call:
if (me.fireEvent('beforestartedit', me, me.boundEl, value) !== false)
parseDate: function(value) {
if (!value || Ext.isDate(value)) {
return value;
}
var me = this,
val = me.safeParse(value, me.format),
altFormats = me.altFormats,
altFormatsArray = me.altFormatsArray,
i = 0,
len;
if (!val && altFormats) {
altFormatsArray = altFormatsArray || altFormats.split('|');
len = altFormatsArray.length;
for (; i < len && !val; ++i) {
val = me.safeParse(value, altFormatsArray[i]);
}
}
return val;
}
in non working project, value is xml-like: 2015-06-27T00:00:00 and val is nullin working project, value is Sat Jun 27 2015 00:00:00 GMT+0200 (ora legale Europa occidentale)
it seems that altFormats does not have a format for xml date.
Demo page is this one:
<%@ Page Language="vb" AutoEventWireup="false" %>
<!DOCTYPE html>
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim rm As New ResourceManager
Me.form1.Controls.Add(rm)
Me.form1.Controls.Add(GetGridPanel())
End Sub
Private Function GetGridPanel() As GridPanel
'
' Data Store
'
Dim m As New Model
m.Fields.Add("Num", ModelFieldType.Int)
m.Fields.Add("Data", ModelFieldType.Date)
Dim s As New Store
s.ID = "MyStore"
s.DataSource = GetCustomDataSource()
s.Model.Add(m)
'
' Building Grid
'
Dim grd As New GridPanel With {
.ID = "MyGrid",
.Width = 300,
.Header = 200,
.Title = "Grid"}
grd.ColumnModel.Columns.Add(New Column With {.DataIndex = "Num", .Text = "Num"})
grd.ColumnModel.Columns.Add(New DateColumn With {.DataIndex = "Data", .Text = "Data", .Format = "dd/m/Y"})
grd.ColumnModel.Columns(1).Editor.Add(New DateField With {.Format = "dd/m/Y"})
grd.Store.Add(s)
Dim p As New CellEditing With {.ClicksToEdit = 1}
grd.Plugins.Add(p)
Return grd
End Function
Public Shared Function GetCustomDataSource() As System.Data.DataTable
Dim dt As New System.Data.DataTable
dt.Columns.Add("Num", GetType(Integer))
dt.Columns.Add("Data", GetType(Date))
For n = 0 To 11
Dim r = dt.NewRow
r.Item("Num") = n
r.Item("Data") = Now.Date.AddDays(-1 * (New Random(n)).Next(1000))
dt.Rows.Add(r)
Next
dt.AcceptChanges()
Return dt
End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
is it something you did experience before?Have I been able to give you enough info in order you to help me?
Thank you, I know that until it works it is difficult to fix... it is complicated to include the whole project.
I'll carry on investigating.
Last edited by Dimitris; Jul 09, 2015 at 7:14 PM.
Reason: [CLOSED]