PDA

View Full Version : [CLOSED] DateTime format renderer in GridPanel



speedstepmem4
Oct 22, 2013, 10:08 AM
Hi,

What is the date format and datetime format using gridpanel renderer function?

Daniil
Oct 22, 2013, 3:30 PM
Hi @speedstepmem4,

You can use a DateColumn specifying some Format for that. A Format should be a .NET date time format string.

geoffrey.mcgill
Oct 22, 2013, 4:53 PM
Hi,

What is the date format and datetime format using gridpanel renderer function?

This functionality is provided is almost every single (several dozen) GridPanel demo in the Examples Explorer.

http://examples2.ext.net/#/GridPanel/ArrayGrid/Simple/

Please click the "Source Code" button to review how the functionality is configured.

speedstepmem4
Oct 23, 2013, 6:10 AM
This functionality is provided is almost every single (several dozen) GridPanel demo in the Examples Explorer.

http://examples2.ext.net/#/GridPanel/ArrayGrid/Simple/

Please click the "Source Code" button to review how the functionality is configured.

Thanks,

how hide default date in Ext.DateColumn in GridPanel?

Please check attached image

Daniil
Oct 23, 2013, 6:29 AM
No default date is shown in the test case bellow. Please provide your test case.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
Store store = this.GridPanel1.GetStore();
store.DataSource = new object[]
{
new object[] { "test", DateTime.Now },
new object[] { "test" },
new object[] { "test", DateTime.Now }
};
}
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:GridPanel ID="GridPanel1" runat="server">
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="test" />
<ext:ModelField Name="date" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Test" DataIndex="test" />
<ext:DateColumn runat="server" Text="Date" DataIndex="date" />
</Columns>
</ColumnModel>
</ext:GridPanel>
</form>
</body>
</html>

speedstepmem4
Oct 24, 2013, 5:27 AM
No default date is shown in the test case bellow. Please provide your test case.


Hi Daniil,

Please find my blow sample. DOJ property should be null able date type , so DOj column is showing empty. But DOB and DOC is showing default date like this 01010001. These DOB and DOC was not showed default value in v1.x. Please check the sample and provide your suggestion.



<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
Store store = this.GridPanel1.GetStore();
List<Sample> list = new List<Sample>() { new Sample { Name = "adc", DOJ = null } };

store.DataSource = list;
store.DataBind();
}
}

private class Sample
{
public string Name { get; set; }
public DateTime DOB { get; set; }
public DateTime? DOJ { get; set; }
private DateTime _doc = new DateTime();
public DateTime DOC { get { return _doc; } set { _doc = value; } }
}

</script>
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:GridPanel ID="GridPanel1" runat="server" Layout="FitLayout" Width="600">
<Store>
<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
<ext:ModelField Name="Name" />
<ext:ModelField Name="DOB" Type="Date" />
<ext:ModelField Name="DOJ" Type="Date"/>
<ext:ModelField Name="DOC" Type="Date"/>
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column ID="Column1" runat="server" Text="Test" DataIndex="Name" />
<ext:Column ID="Column2" runat="server" Text="DOB" DataIndex="DOB" />
<ext:DateColumn ID="DateColumn1" runat="server" Text="DOC" DataIndex="DOC">
<Renderer Fn="Ext.util.Format.dateRenderer('m/d/Y')" />
</ext:DateColumn>
<ext:DateColumn ID="DateColumn2" runat="server" Text="DOJ" DataIndex="DOJ" />
</Columns>
</ColumnModel>
</ext:GridPanel>
</form>
</body>
</html>



I used Format property also, the issue happened.


<Columns>
<ext:Column ID="Column1" runat="server" Text="Test" DataIndex="Name" />
<ext:Column ID="Column2" runat="server" Text="DOB" DataIndex="DOB" />
<ext:DateColumn ID="DateColumn1" runat="server" Text="DOC" DataIndex="DOC" Format="m/d/Y">
<%--<Renderer Fn="Ext.util.Format.dateRenderer('m/d/Y')" />--%>
</ext:DateColumn>
<ext:DateColumn ID="DateColumn2" runat="server" Text="DOJ" DataIndex="DOJ" />
</Columns>


Please check the attachment.

Daniil
Oct 24, 2013, 6:32 AM
Thank you for a test case. We are investigating why the behavior has been changed and a possibility to change it back.

For now, to revert back the old behavior, please use:

protected void Page_Load(object sender, EventArgs e)
{
JSON.GlobalSettings.Converters.Add(new JSONDateTimeJsonConverter());

/* all the rest code */
}

It might be better to call it in Global.asax in an Application_Start handler.

Another issue. Yes, please use a DateColumn's Format instead of Renderer.

Daniil
Oct 25, 2013, 2:56 PM
We are investigating why the behavior has been changed and a possibility to change it back.

It has been fixed in the SVN trunk.

Here is a related thread for references.
http://forums.ext.net/showthread.php?26336