1. #1
    Sencha User
    Join Date
    Sep 2008
    Posts
    46
    Vote Rating
    0
    ajain is on a distinguished road

      0  

    Default Date picker default year display

    Date picker default year display


    Hi,

    I need to display date in an editable grid column along with the date picker. The date in json object is in the form mm/dd/yy. I am using the date format m/d/y in Ext to display it. It displays correctly. But the problem is with the date picker. If I click on a cell with a date with year greater than 50 (1950) then the date picker shows the default year selected as 1950. But if I do the same for a cell with date with year less than or equal to 50(1950) the datepicker shows the sellected year as 2050. Why is this happening? How can I fix it?

    var colModel = new Ext.grid.ColumnModel([{
    header:'DOB estimated',
    width:95,
    dataIndex:'dob',
    renderer: Ext.util.Format.dateRenderer('m/d/y'),
    editor: new Ext.form.DateField({
    format: 'm/d/y'

    })
    }

    var record = new Ext.data.Record.create([
    {name: 'dob', mapping: 'cps_uploadfile_DOB',type: 'date', dateFormat: 'm/d/y'},
    ]);

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    96
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    When using a 2-digit year it is normal to define a year window, e.g.

    Code:
    >= 50 -> 1950-1999
    < 50 -> 2000-2049
    You can change the window by setting:

    Code:
    Ext.Date.y2kYear = 90;
    (but you really should start using 4-digit years)

  3. #3
    Sencha User
    Join Date
    Sep 2008
    Posts
    46
    Vote Rating
    0
    ajain is on a distinguished road

      0  

    Default


    I will take your suggestion to change the year to 4 digits. But out of curiosity I would like to know where should I set Ext.Date.y2kYear = 90; ?

  4. #4
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    96
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Directly after including ext-all.js, even before your Ext.onReady().

    ps. You only have to start using 4-digit years in the JSON data.

  5. #5
    Sencha User
    Join Date
    Sep 2008
    Posts
    46
    Vote Rating
    0
    ajain is on a distinguished road

      0  

    Default


    Yes, I have changed my json daa to have 4 digit years.
    Adding Ext.Date.y2kYear = 90; gives me the following error -

    Ext.Date is undefined

  6. #6
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    96
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Oops... I'm just too Ext-ified.

    It's simply:
    Code:
    Date.y2kYear = 90;

  7. #7
    Sencha User
    Join Date
    Sep 2008
    Posts
    46
    Vote Rating
    0
    ajain is on a distinguished road

      0  

    Default


    That didn't give me any error, but it made the problem worse. Now all years no matter >1950 or <=1950 are showing as >2000 eg. 1960 showing up as 2060 in datepicker

  8. #8
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    96
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    That is exactly what I said:
    Code:
    >= 90 -> 1990-1999
    < 90 -> 2000-2089
    Did you want:
    Code:
    Date.y2kYear = 9;

  9. #9
    Sencha User
    Join Date
    Sep 2008
    Posts
    46
    Vote Rating
    0
    ajain is on a distinguished road

      0  

    Default


    Got it now! Thanks so much!!

  10. #10
    Sencha User
    Join Date
    Oct 2009
    Location
    Rome
    Posts
    49
    Vote Rating
    0
    spizzico7 is on a distinguished road

      0  

    Default


    Sorry but i have a problem with Date.y2kYear = 9; if i use this the date after 1950 ex: 2010 show in 1910.

    What is right setting for show date after and before 1949?

Thread Participants: 2