[CLOSED] Format Date in Custom Drop Down List

  1. #1

    [CLOSED] Format Date in Custom Drop Down List

    I have the following custom drop down list based on your example;

    
              <ext:Store ID="Store1" runat="server">
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="EngagementID" />
                            <ext:RecordField Name="Engagement" />
                            <ext:RecordField Name="EndDate"  />
                        </Fields>
                    </ext:ArrayReader>
                </Reader>            
            </ext:Store>
    
            <ext:ComboBox 
                ID="ComboBox1" 
                runat="server"
                StoreID="Store1" 
                Width="250"
                Editable="false"
                DisplayField="Engagement"
                ValueField="EngagementID"
                TypeAhead="true" 
                Mode="Local"
                ForceSelection="true"
                TriggerAction="All"
                ItemSelector="div.list-item"
                SelectOnFocus="true">
                <Template runat="server">
                    <Html>
                        <tpl for=".">
                            <div class="list-item">
                                 <h3>{Engagement}</h3>
                                 {EndDate}
                            </div>
                        </tpl>
                    </Html>
                </Template>    
            </ext:ComboBox>
    How do I set the format of the EndDate to say 'MM/dd/yy' in the dropdown?

    I tried setting the DateFormat of the EndDate RecordField, but that didn't work.

    thanks
    Last edited by Daniil; Jul 29, 2011 at 1:33 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Just set up a respective format function.
    {date:date("Y-m-d")}
    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.ComboBox1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { DateTime.Now },
                    new object[] { DateTime.Now.AddDays(1) },
                    new object[] { DateTime.Now.AddDays(2) }
                };
                store.DataBind();
            }
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:ComboBox 
                ID="ComboBox1" 
                runat="server" 
                ValueField="date" 
                DisplayField="date">
                <Store>
                    <ext:Store runat="server">
                        <Reader>
                            <ext:ArrayReader>
                                <Fields>
                                    <ext:RecordField Name="date" />
                                </Fields>
                            </ext:ArrayReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <Template runat="server">
                    <Html>
                        <tpl for=".">
                            <div class="list-item">
                                {date:date("Y-m-d")}
                            </div>
                        </tpl>
                    </Html>
                </Template>
            </ext:ComboBox>
        </form>
    </body>
    </html>
    Another available format functions are here:
    http://dev.sencha.com/deploy/ext-3.4...xt.util.Format
  3. #3
    Thanks, that worked perfectly! You can close this thread.

Similar Threads

  1. Replies: 3
    Last Post: May 09, 2012, 4:28 PM
  2. Replies: 1
    Last Post: Apr 13, 2012, 1:52 PM
  3. Replies: 4
    Last Post: Jun 30, 2011, 3:30 PM
  4. [CLOSED] How to Set Date Format in a Coolite Date Field
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 02, 2010, 8:47 AM
  5. [CLOSED] [1.0] Custom Drop Down List Example
    By Ben in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jan 27, 2010, 11:20 AM

Posting Permissions