1. #1
    Touch Premium Member
    Join Date
    Jun 2010
    Posts
    324
    Vote Rating
    2
    profunctional is on a distinguished road

      0  

    Default How to set datepickerfield to default to today's date after opening it.

    How to set datepickerfield to default to today's date after opening it.


    I have a datepickerfield that by default should be null. However, if the user clicks to select the date, it currently defaults to 1/1/2000. I'd like to have the date default to today's date.

    How do I do this?

  2. #2
    Sencha User
    Join Date
    Sep 2011
    Posts
    43
    Vote Rating
    0
    bassjobsen is on a distinguished road

      0  

    Default


    Hi,

    You can set;

    Code:
    value : { day: new Date().getDate(), month: (new Date().getMonth()+1), year : new Date().getFullYear()}
    b.e.
    Code:
                  {
                    xtype: "datepickerfield",
                    name: "date",
                    label: null,
            id : "lastdate",
                    picker: { yearFrom: 2011, yearTo: 2012},
                    value : { day: new Date().getDate(), month: (new Date().getMonth()+1), year : new Date().getFullYear()}
                  }

  3. #3
    Touch Premium Member
    Join Date
    Jun 2010
    Posts
    324
    Vote Rating
    2
    profunctional is on a distinguished road

      0  

    Default


    Thanks for the tip. Unfortunately I've already tried this. The date still defaults to 1/1/2011. I wonder if it is a bug.
    Quote Originally Posted by bassjobsen View Post
    Hi,

    You can set;

    Code:
    value : { day: new Date().getDate(), month: (new Date().getMonth()+1), year : new Date().getFullYear()}
    b.e.
    Code:
                  {
                    xtype: "datepickerfield",
                    name: "date",
                    label: null,
            id : "lastdate",
                    picker: { yearFrom: 2011, yearTo: 2012},
                    value : { day: new Date().getDate(), month: (new Date().getMonth()+1), year : new Date().getFullYear()}
                  }

  4. #4
    Touch Premium Member
    Join Date
    Jun 2010
    Posts
    324
    Vote Rating
    2
    profunctional is on a distinguished road

      0  

    Default


    I take it back that worked. But I remember why I couldn't do it like this. The field should be blank by default. But when the user taps the field I'd like to default it to today's date. I'm looking for a tap event for the field or something, which I don't see in the docs.

  5. #5
    Sencha User
    Join Date
    Sep 2011
    Posts
    43
    Vote Rating
    0
    bassjobsen is on a distinguished road

      0  

    Default


    Well, okay
    There are more threads like this b.e. http://www.sencha.com/forum/showthre...-on-lost-focus

    You have to find the event which is fired before the select popup come up.
    So you can add a listener like:
    Code:
    listeners: 
    {
            idontkown : function()
        {
            this.setValue();
        }
    }
    select is fired after selecting a date so you need someting like beforeselect

  6. #6
    Sencha User
    Join Date
    Sep 2011
    Posts
    43
    Vote Rating
    0
    bassjobsen is on a distinguished road

      0  

    Default


    Try this:
    Code:
    {
                    xtype: "datepickerfield",
                    name: "date",
                    label: null,
            id : "lastdate",
                    picker: { yearFrom: 2011, yearTo: 2012},
                    listeners: {
                click: 
            {
                    element: 'el', 
                    fn: function()    { 
                               Ext.getCmp('lastdate').getDatePicker().setValue(new Date());//set today
                                       }
                }
    }

  7. #7
    Touch Premium Member
    Join Date
    Jun 2010
    Posts
    324
    Vote Rating
    2
    profunctional is on a distinguished road

      0  

    Default


    You are genius! This worked perfectly. Thank you so much!
    Quote Originally Posted by bassjobsen View Post
    Try this:
    Code:
    {
                    xtype: "datepickerfield",
                    name: "date",
                    label: null,
            id : "lastdate",
                    picker: { yearFrom: 2011, yearTo: 2012},
                    listeners: {
                click: 
            {
                    element: 'el', 
                    fn: function()    { 
                               Ext.getCmp('lastdate').getDatePicker().setValue(new Date());//set today
                                       }
                }
    }

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi