1. #1
    Sencha User
    Join Date
    May 2012
    Posts
    21
    Vote Rating
    0
    Answers
    2
    Greezer is on a distinguished road

      0  

    Default Answered: Form.reset() and datepicker issue

    Answered: Form.reset() and datepicker issue


    I have a form with two datepicker fields. If I select some date, then clear my form (button who throws the form.reset() method) and want to reselect some date, I get the following console message :

    Uncaught TypeError: Cannot call method 'toDateString' of null

    Anyone already had the same issue ?


    For information, same issue appears when I clear only the datepicker field with my custom datepicker clear button, code's here :

    Code:
                         {
                              xtype: 'datepickerfield',
                              itemId: 'dateFromField',
                              name: 'dateFrom',
                              locales: {                          
                                label: 'fields.dateFrom'
                              },
                              dateFormat: 'd/m/Y',                           
                              picker : {                              
                                  toolbar : {
                                      items : [
                                          {
                                              locales: {                          
                                                text: 'buttons.clear'
                                              },
                                              ui      : 'decline',
                                              align   : 'right',
                                              handler : function(btn) {
                                                  var picker = btn.up('datepicker');
                                                  picker.fireEvent('change', picker, null);
                                                  picker.hide();
                                              }
                                          }
                                      ]
                                  },
                                  enableLocale : true,
                                  locales: {
                                    months: 'months'
                                  },
                                  yearFrom: 2010,
                                  slotOrder:['day', 'month', 'year'] 
                              }
                          },



  2. What ST2 version are you using? I just tried this with 2.0.0 and 2.0.1.1 and it works without any errors:

    Code:
    new Ext.form.Panel({
        fullscreen : true,
        items      : [
            {
                xtype : 'datepickerfield',
                label : 'Date'
            },
            {
                xtype   : 'button',
                text    : 'Reset',
                handler : function(button) {
                    var form = button.up('formpanel');
    
                    form.reset();
                }
            }
        ]
    });

  3. #2
    Sencha User
    Join Date
    Apr 2012
    Location
    ShenZhen, China
    Posts
    52
    Vote Rating
    2
    Answers
    11
    liaoyiwu is on a distinguished road

      0  

    Default


    Need a value property

  4. #3
    Sencha User
    Join Date
    May 2012
    Posts
    21
    Vote Rating
    0
    Answers
    2
    Greezer is on a distinguished road

      0  

    Default


    Ok thank you, it works if I set the value.

    But then, if I want to allow the possibility to doesn't specify the date, how can I do it ?

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,684
    Vote Rating
    435
    Answers
    3111
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    What ST2 version are you using? I just tried this with 2.0.0 and 2.0.1.1 and it works without any errors:

    Code:
    new Ext.form.Panel({
        fullscreen : true,
        items      : [
            {
                xtype : 'datepickerfield',
                label : 'Date'
            },
            {
                xtype   : 'button',
                text    : 'Reset',
                handler : function(button) {
                    var form = button.up('formpanel');
    
                    form.reset();
                }
            }
        ]
    });
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  6. #5
    Sencha User
    Join Date
    May 2012
    Posts
    21
    Vote Rating
    0
    Answers
    2
    Greezer is on a distinguished road

      0  

    Default


    I just update the SDK to 2.0.1.1 and it works, I was with the 2.0.1... Don't know what was wrong !
    Thank you