[CLOSED] DateField Customisation

  1. #1

    [CLOSED] DateField Customisation

    I am looking to give some more ease to the end user to allow multiple formats of date.

    For example i want the date field Accepts typed-in dates in various formats:
    1.1.13
    01-01-2013
    1 Jan 13
    1Jan
    1 January

    Currently the control allows to give format string, but that is only one format i can give (dd/MM/yyyy) or (dd.MM.yyyy).

        @(Html.X().DateField().ID("myDate").Format("dd/MM/yyyy"))
    Can you suggest me how to customize existing DateField control?

    Thanks,
    Rajiv Dutt
    Last edited by Daniil; Dec 24, 2013 at 8:25 AM. Reason: [CLOSED]
  2. #2
    Hi @RajivDutt,

    It looks you are looking for a DateField's AltFormats property.
    http://docs-origin.sencha.com/extjs/...cfg-altFormats
  3. #3

    AltFormat

    Quote Originally Posted by Daniil View Post
    Hi @RajivDutt,

    It looks you are looking for a DateField's AltFormats property.
    http://docs-origin.sencha.com/extjs/...cfg-altFormats
    Thanks, it looks like a good choice, but there are some issues, after i use the AltFormat.

    As per the default behavior when i type 11/12 and press Tab... it converts it to 11/12/2013. Which is my requirement as well.
    But after applying the AltFormat Property, this default behavior goes away.

    Sample Code :
        @(Html.X().DateField().ID("myDate").Format("dd/MM/yyyy").AltFormats("dd.MM.yyyy"))
  4. #4
    Hello!

    To do so you need to add another AltFormat value:

    @(Html.X().DateField().ID("myDate").Format("dd/MM/yyyy").AltFormats("dd.MM.yyyy|m/d"))
    It worked before because by default AltFormat has the following value:

    m/d/Y|n/j/Y|n/j/y|m/j/y|n/d/y|m/j/Y|n/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d|Y-m-d|n-j|n/j
  5. #5
    Quote Originally Posted by Baidaly View Post
    Hello!

    To do so you need to add another AltFormat value:

    @(Html.X().DateField().ID("myDate").Format("dd/MM/yyyy").AltFormats("dd.MM.yyyy|m/d"))
    It worked before because by default AltFormat has the following value:

    m/d/Y|n/j/Y|n/j/y|m/j/y|n/d/y|m/j/Y|n/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d|Y-m-d|n-j|n/j

    Thanks, it works great. Now if i want to implement Jan & January also, what will be the AltFormat?
  6. #6
  7. #7
    Please note that AltFormats should be set up using the .NET data/time format. When it will be converted to the PhP format automatically. Ext.NET and ExtJS operates with the PhP date/time format on client.

Similar Threads

  1. Datefield
    By Felipe Torres in forum 2.x Help
    Replies: 1
    Last Post: Mar 06, 2013, 2:04 PM
  2. Replies: 6
    Last Post: Jan 09, 2013, 10:30 AM
  3. Cannot set value of DateField
    By zhaoxl in forum 1.x Help
    Replies: 2
    Last Post: Feb 08, 2012, 6:48 AM
  4. DateField and ASP.NET MVC
    By DavidS in forum 1.x Help
    Replies: 2
    Last Post: Jul 06, 2011, 6:16 AM
  5. DateField Bug
    By dannyrih in forum 1.x Help
    Replies: 2
    Last Post: Jan 04, 2010, 3:06 PM

Tags for this Thread

Posting Permissions