PDA

View Full Version : [CLOSED] date rendering in grid panel



EddieJensen
Sep 24, 2013, 10:33 PM
Hi all,

I am having a problem with the grid panel, when I use a date column some of the dates are not being rendered correctly.
I have built a little demo that demonstrates the problem. What happens is the records are simply blank, and it appears to only happen when the day part of the date is <= 9. I need to use the DateColumn and not just a standard column because I am using client side filtering and it doesn't work properly without using a DateColumn. It also doesn't seem to matter what format I use for the date values e.g. Y/m/d or d/m/y etc

It may this is a bug, but more likely I am just doing something wrong :) I am using C# and MVC, and using Ext 4.0, Ext.Net 2.2

here is the controller code



public class HomeController : Controller
{
public ActionResult StoreData()
{
return Content(@"
[{
""contractedShipDate"": null
},{
""contractedShipDate"": ""2007-02-22""
},{
""contractedShipDate"": ""2013-03-13""
},{
""contractedShipDate"": ""2012-12-18""
},{
""contractedShipDate"": ""2010-11-03""
},{
""contractedShipDate"": ""2012-12-09""
}
]");
}
}
}

and here is the view



@(Html.X().GridPanel()
.Width(600)
.Height(300)
.Store(store => store.Add(Html.X().Store()
.AutoLoad(true)
.Proxy(proxy => proxy.Add(Html.X().AjaxProxy()
.Url(Url.Content(@"~/Home/StoreData"))
)
)
.Model(mdl => mdl.Add(Html.X().Model()
.Fields(fields => fields.Add(Html.X().ModelField()
.Name("contractedShipDate")
.Type(Ext.Net.ModelFieldType.Date)
.DateReadFormat("Y-m-d")
)
)
)
)
)
)
.ColumnModel(col => col.Columns.Add(Html.X().DateColumn()
.DataIndex("contractedShipDate")
.Format("d/m/Y")
)
)
)

If anyone has any idea's I would greatly appreciate your feedback.

Cheers,
Eddie

Daniil
Sep 25, 2013, 5:14 AM
Hi Eddie,

Please use:

.DateReadFormat("yyyy-MM-dd")

It expects a .NET date format string.

EddieJensen
Sep 25, 2013, 8:25 PM
Daniil, thanks for your reply. That was the problem and it's working perfectly now, thanks a lot :)