[FIXED] DatePicker date format dd/MM/yyyy not working

  1. #1

    [FIXED] DatePicker date format dd/MM/yyyy not working

    I'm using the DatePicker control and I can't get the date showing in format dd/MM/yyyy. It seems the Format property is not working at all. Am I missing something?
  2. #2

    RE: [FIXED] DatePicker date format dd/MM/yyyy not working



    Hi alterin,

    Unfortunately the date formatting within the DatePicker is one (if not the only) place where there is a serious disconnect/conflict between the ExtJS framework and .NET.

    Ext uses a PHP/Unix style of date format specifiers, which is not compatible with the .NET/Java syntax.

    At the moment I do not have a good solution for this, but it will be fixed in an upcoming release (not 0.4, but probably 0.5). For now the "MM/dd/yyyy" is the only format that will reliably work.
    Geoffrey McGill
    Founder
  3. #3

    RE: [FIXED] DatePicker date format dd/MM/yyyy not working

    Hi,

    I ended up with
    "dd.MM.yyyy".Replace("dd", "d").Replace("MM", "m").Replace("yyyy", "Y")
  4. #4

    RE: [FIXED] DatePicker date format dd/MM/yyyy not working

    Even without specifying format, there is a bug. I'm just using:

    <cool:DatePicker ID="DatePickerMapDate" runat="server" />

    And on each post back the days and month swaps (i.e. I put 01/03/08 and after a postback the date changes to 03/01/08). Furthermore, I can never select a day > than 12 otherwise I get:

    [FormatException: String was not recognized as a valid DateTime.]
       System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) +2273210
       System.DateTime.Parse(String s) +22
       Coolite.Web.UI.DatePicker.get_SelectedDate() +110
       Coolite.Web.UI.DatePicker.LoadPostData(String postDataKey, NameValueCollection postCollection) +170
       Coolite.Web.UI.Field.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) +11
       System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +661
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1194
    I think this is related to the swaping day/month.


    Another bug is that when it's inside an UpdatePanel, on postbacks, there's a duplicate calendar icon for the calendar textbox (both icons are functional; the duplicate icon appears at the begining of the textbox, hiding the day)
  5. #5

    RE: [FIXED] DatePicker date format dd/MM/yyyy not working

    The bug with duplicate icons is due to the recreation of the date picker (reinitialization of the ext object). When the control is in an updatepanel, and that the panel is being recreated through an async postback, the bug doesn't occur (it's doing what it's supposed to; recreating the control). But when the update panel is not being updated, the control doesn't need to be recreated. Doing so, creates a duplicate button.

    As for the bug about the format, you guys can use the parseExact instead of just parse, so that months and days doesn't get swapped on PCs that has different regional settings.

    Hope it helps,

    PS: Great job btw, can't wait for the next release.
  6. #6

    RE: [FIXED] DatePicker date format dd/MM/yyyy not working

    Hi Dan,

    I apologize for not responding earlier. I've been tinkering with the DatePicker today and have the date parsing working correctly. I'm diving back into the DatePicker later today, so I'll post an update if I find a work-around to use with the current (0.4.1) release. Otherwise, the new code/fix will be included with the next release.

    I was also changing up the how the onReady script gets generated when the controls are in an Async postback. It's been a bit tricky to get this all working with the UpdatePanel, but everything should be working smoothly for the next release.
    Geoffrey McGill
    Founder
  7. #7

    RE: [FIXED] DatePicker date format dd/MM/yyyy not working

    Thanks for the reply,

    Yeah I figured it was tricky. I created a user control in order to fix the bug and I noticed the challenge. I ended up caling my reinitialize ext component function manually whenever I'm updating my update panel. Not ideal, but it's a quick fix :)
  8. #8

    RE: [FIXED] DatePicker date format dd/MM/yyyy not working

    Hi,

    I managed to fix this problem.
    This is what i did to setup the DatePicker for working with Dutch dateformats:

    1) include the .js localisation file from the Ext sourcecode (called ext-lang-nl.js in my case) on the page.
    2) doublecheck that the Ext DateField settings in this file are appropriate for your country (see Ext docs Date object), in my case they are:



    format : "d-m-Y",
    altFormats : "d-m-y|j-n-y|j-n-Y|d/m/y|j/n/y|j/n/Y",
    
    3) make sure that you set the Format property of the Coolite DatePicker server control to a .Net dateformat string, in my case:

     dp = new Coolite.Web.UI.DatePicker{
        Format = "dd-MM-yyyy",
        ...
    });
    I hope this helps.

    Martijn.
  9. #9

    RE: [FIXED] DatePicker date format dd/MM/yyyy not working

    These DateFormat and UpdatePanel bugs have been fixed in the 0.5 release.

    Please let me know if you run into any issues and we'll do our best to patch immediately.
    Geoffrey McGill
    Founder

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: 1
    Last Post: Dec 15, 2011, 12:38 AM
  4. DatePicker: get Min Date and Max Date just displayed
    By Journeyman79 in forum 1.x Help
    Replies: 0
    Last Post: Mar 16, 2011, 10:41 AM
  5. Replies: 2
    Last Post: Mar 17, 2010, 9:29 AM

Posting Permissions