Results 1 to 7 of 7

Thread: [3.0-rc1] DateField menuListeners

  1. #1
    Sencha User TopKatz's Avatar
    Join Date
    Mar 2007
    Posts
    340

    Default [3.0-rc1] DateField menuListeners

    I have some DateFields that I was using menuListeners on to use some custom behavior in 2.x. Did this change? I inspected the field, and still see menuListener.select() in there, however this is not working now:

    Code:
      this.weDateField = new Ext.form.DateField({
                disabledDays:[0,1,2,3,4,5],
                value:'',           
                menuListeners:{
                    select : function(){
                         var date = this.weDateField.menu.picker.activeDate;
                         this.weDateField.setValue(date);
                         this.reloadWEDate();
                    },
                    scope:this
                }
            });
    Even if I just stick a console.log('test') in the select I get nothing.

    Thanks in advance

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    1. Yes, this changed in Ext 3.0.
    2. Your code doesn't work properly in Ext 2.x. You need:
    Code:
    menuListeners: Ext.applyIf({
      select: function(m, d){
        this.constructor.prototype.menuListeners.select.apply(this, arguments);
        ...
      }
    }, Ext.form.DateField.prototype.menuListeners)
    (and you can't set the scope unless you use createDelegate)
    3. In Ext 3.0 you can use:
    Code:
    onSelect: function(m, d){
      this.constructor.prototype.onSelect.apply(this, arguments);
      ...
    }
    4. But the recommended method for 2.2.1 and 3.0 is to use a simple 'select' listener.

  3. #3
    Sencha User TopKatz's Avatar
    Join Date
    Mar 2007
    Posts
    340

    Default

    Quote Originally Posted by Condor View Post
    ...
    4. But the recommended method for 2.2.1 and 3.0 is to use a simple 'select' listener.
    Are you saying to use the datepickers select? If I remember this did not work as expected before. Ill try that.

    BTW - this code is working in 2.x

  4. #4
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    1. The select event was introduced in Ext 2.2.1 (your code probably predates Ext 2.2.1).
    2. menuListeners contains 3 listeners (select, show and hide), so your method effectively kills the show and hide listeners on the inner DateMenu.

  5. #5
    Sencha User TopKatz's Avatar
    Join Date
    Mar 2007
    Posts
    340

    Default

    your right, regular old select is working fine. Not sure how I landed on menuListeners before. I know I had issues getting select to work.

    Thanks

    Katz

  6. #6

    Default dateField menuListeners.select problem

    Hi,
    I am facing following problem while using menuListeners.select in my application.
    Problem:
    In my application i am using three date fields in x page. I have applied menuListeners.select for first date field. select event for first date field is working fine but all other two date fields are also getting same select effect.

  7. #7
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Quote Originally Posted by sureshraja.crt View Post
    Hi,
    I am facing following problem while using menuListeners.select in my application.
    Problem:
    In my application i am using three date fields in x page. I have applied menuListeners.select for first date field. select event for first date field is working fine but all other two date fields are also getting same select effect.
    So you're making the same mistake!

    I already listed the solutions in my previous post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •