[CLOSED] GridPanel date column in customer format

  1. #1

    [CLOSED] GridPanel date column in customer format

    i would like to show date format at column (yyyy/MM/dd), but following code will show empty in Grid. what dateFormat string should i use?

    If objLstOfProp(i).ExtNetModelType = Ext.Net.ModelFieldType.Date Then
              objModel.Fields.Add(objLstOfProp(i).Name, objLstOfProp(i).ExtNetModelType, "yyyy/MM/dd") ''<-- Question in here
    Else
              objModel.Fields.Add(objLstOfProp(i).Name, objLstOfProp(i).ExtNetModelType)
    End If
    Last edited by Daniil; Dec 12, 2012 at 12:29 PM. Reason: [CLOSED]
  2. #2
    You need to set the Column's Format (Line 23) instead of ModelField's DateFormat, as shown below:

    1 - ASPX
    <!DOCTYPE html>
    <html>
    <head id="Head1" runat="server">
    </head>
    <body>
        <ext:ResourceManager runat="server" />
        <ext:GridPanel Title="Example" Width="600" Height="350" runat="server">
            <Store>
                <ext:Store ID="Store1" runat="server">
                    <Model>
                        <ext:Model runat="server">
                            <Fields>
                                <ext:ModelField Name="Name" />
                                <ext:ModelField Name="BirthDate" Type="Date" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel>
                <Columns>
                    <ext:Column Text="Name" DataIndex="Name" Flex="1" runat="server" />
                    <ext:DateColumn Format="Y/m/d" Text="Birth" DataIndex="BirthDate" runat="server" />
                </Columns>
            </ColumnModel>
        </ext:GridPanel>
    </body>
    </html>
    2 - Code Behind
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.Store1.DataSource = this.Data;
                this.Store1.DataBind();
            }
        }
    
        private List<People> Data
        {
            get
            {
                return new List<People>
            {
                new People { Name = "Ext", BirthDate = DateTime.Now },
                new People { Name = "Net", BirthDate = DateTime.Now.AddDays(1) },
                new People { Name = "Ext.Net", BirthDate = DateTime.Now.AddYears(1) },
            };
            }
        }
    }
    3 - Utility
    public class People
    {
        public string Name { get; set; }
    
        public DateTime BirthDate { get; set; }
    }
    Please let me know whether the example helps you
    Last edited by RCN; Dec 08, 2012 at 5:23 AM.
  3. #3
    It would be interesting you read the following thread: http://forums.ext.net/showthread.php...-from-C-to-Ext

Similar Threads

  1. Replies: 1
    Last Post: Apr 13, 2012, 1:52 PM
  2. [CLOSED] Gridpanel format date d/m/y
    By Marcelo in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Sep 30, 2011, 8:46 PM
  3. Format Date GridPanel
    By gpcontreras in forum 1.x Help
    Replies: 0
    Last Post: Jun 13, 2010, 11:25 PM
  4. Replies: 0
    Last Post: Jul 07, 2009, 4:34 AM
  5. [CLOSED] Gridpanel Date Format
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: May 04, 2009, 4:03 PM

Posting Permissions