Combobox show current date

  1. #1

    Combobox show current date

    Hello,
    I am trying to create a combobox and assign the displayfield with current date in 2 different formats.
    How can I achieve that?
    Here is my current code with static values:

    <ext:ComboBox  runat="server" ID="cmbFormatFFC"   DataIndex="DateFormat"          FieldLabel="Date Format"             Width="400" ForceSelection="true" EmptyText="Select date format...">
           <Items>
                  <ext:ListItem Text="1/1/2017" Value="d/M/yyyy" />
                  <ext:ListItem Text="1-JAN-2017" Value="dd-MMM-yyyy" />
           </Items>
    </ext:ComboBox>
  2. #2
    Hello @atroul!

    Combo boxes are but string entries so, in order to format dates you should be using the Date object, if client side, and System.DateTime from server-side.

    They can also bind a Model to the combo box, which you can determine the DisplayField and ValueField, so you may also have two fields in that model, one containing the nice formatted date and the other with the raw date, or just one field in the Date format, and defining the conversion in one of the possible manners.

    You can use most of this: Ext.NET Grid Panel Column Variations

    In which the data template can be used with the combo box instead of a grid panel following this example: Combo Box - Custom Dropdown List.

    I hope this helps!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] how to show current date in DateField control?
    By hdsoso in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 18, 2015, 2:25 PM
  2. Replies: 1
    Last Post: Apr 13, 2014, 7:09 AM
  3. [CLOSED] how to select current date to ext:DateField ?
    By hdsoso in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: May 28, 2013, 7:55 AM
  4. Replies: 2
    Last Post: Apr 23, 2012, 12:47 PM
  5. Replies: 1
    Last Post: Jul 30, 2009, 6:33 AM

Tags for this Thread

Posting Permissions