1. #1
    Ext User
    Join Date
    Dec 2007
    Posts
    5
    Vote Rating
    0
    lobo_tuerto is on a distinguished road

      0  

    Question How to remove disabled dates from datepicker

    How to remove disabled dates from datepicker


    Hi guys, I'm working with a date range using 2 date pickers and the validation seen in the examples here:
    http://extjs.com/deploy/dev/examples...dv-vtypes.html

    The problem is that when I reset the form that contains these 2 date fields, the disabled dates don't get cleaned up. How can I reset the disabled dates to nothing?

    Best regards,

  2. #2
    Ext User
    Join Date
    Mar 2009
    Posts
    20
    Vote Rating
    0
    KellanStec is on a distinguished road

      0  

    Default


    Have you tried passing an empty array to the setDisabledDates() method?

  3. #3
    Ext User
    Join Date
    Dec 2007
    Posts
    5
    Vote Rating
    0
    lobo_tuerto is on a distinguished road

      0  

    Default


    Sure, I tried that first, sounds logic, but it ended up disabling ALL days in the date picker.

  4. #4
    Ext User
    Join Date
    Jul 2007
    Posts
    2
    Vote Rating
    0
    Vineesh is on a distinguished road

      0  

    Default


    I am facing the exact same problem....any way to resolve this???

  5. #5
    Sencha User
    Join Date
    Oct 2007
    Location
    Berlin, Germany
    Posts
    891
    Vote Rating
    9
    wm003 will become famous soon enough

      0  

    Default


    In this example the disabled dates are calculated through mindate and maxdate.

    Try

    PHP Code:
    field.setMaxDate(null);    
    field.setMinDate(null); 
    on these fields

    maybe another

    PHP Code:
    field.update 
    is required...

  6. #6
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    This is some Ext 3 code I played with earlier today for another reason, it may help you:

    Code:
    Ext.override(Ext.form.TextField,{
        isBlank : function(){
            var value = this.getRawValue();
            return (value.length < 1 || value === this.emptyText);
        }
    });
    
    // Add the additional 'advanced' VTypes
    Ext.apply(Ext.form.VTypes, {
        daterange : function(val, field) {
            var dependency = Ext.getCmp(field.dependency),
                date = field.parseDate(val);
            if(!date){
                dependency.setMaxValue();
                dependency.setMinValue();
                return;
            }
    
            dependency.allowBlank = false;
            if (!field.dateRange || (date.getTime() != field.dateRange.getTime())) {
                if (field.dependency.indexOf('start') >= 0){
                    dependency.setMaxValue(date);
                } else if (field.dependency.indexOf('end') >= 0){
                    dependency.setMinValue(date);
                    
                }
                field.dateRange = date;
                dependency.validate();
            }
            /*
             * Always return true since we're only using this vtype to set the
             * min/max allowed values (these are tested for after the vtype test)
             */
            return true;
        },
    
        password : function(val, field) {
            if (field.initialPassField) {
                var pwd = Ext.getCmp(field.initialPassField);
                return (val == pwd.getValue());
            }
            return true;
        },
    
        passwordText : 'Passwords do not match'
    });
    
    
    Ext.onReady(function(){
    
        Ext.QuickTips.init();
    
        // turn on validation errors beside the field globally
        Ext.form.Field.prototype.msgTarget = 'side';
    
        var bd = Ext.getBody();
    
    	/*
    	 * ================  Date Range  =======================
    	 */
    
        var syncBlank = function (field){
            var dep = Ext.getCmp(field.dependency);
            if (field.isBlank() && dep.isBlank()){
                dep.allowBlank = true;
                field.allowBlank = true;
                dep.validate();
                field.validate();
            }
        };
        
        var dr = new Ext.FormPanel({
          labelWidth: 125,
          frame: true,
          title: 'Date Range',
    	  bodyStyle:'padding:5px 5px 0',
    	  width: 350,
          defaults: {width: 175},
          defaultType: 'datefield',
          items: [{
            fieldLabel: 'Start Date',
            name: 'startdt',
            id: 'startdt',
            vtype: 'daterange',
            listeners: {
                blur: syncBlank
            },
            dependency: 'enddt' // id of the end date field (must have 'end' in it)
          },{
            fieldLabel: 'End Date',
            name: 'enddt',
            id: 'enddt',
            vtype: 'daterange',
            listeners: {
                blur: syncBlank
            },
            dependency: 'startdt' // id of the start date field (must have 'start' in it)
          }]
        });
    
        dr.render('dr');

  7. #7
    Sencha User
    Join Date
    Nov 2012
    Posts
    6
    Vote Rating
    -1
    tharahan is an unknown quantity at this point

      0  

    Default


    try something like before your form reset

    Ext.getCmp('tradeDateFrom').setMaxValue(null);
    Ext.getCmp('tradeDateFrom').setMinValue(null);