Results 1 to 4 of 4

Thread: Adding & Removing Select Event Listener From Grid

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    61
    Answers
    3
    Vote Rating
    0
      0  

    Default Answered: Adding & Removing Select Event Listener From Grid

    Good day all!!!

    I have a girdpanel to which I'm a select listener function to from my controller. See code below:

    Code:
    init: function()
    {
    this.control(
    {
    'registrationWindow gridpanel[name=Member]':
    {
    select: this.onMemberSelect
    },
    });
    },
    
    onMemberSelect: function(grid, record, index, eOpts)
    {
    console.log('firing member select');
    },
    Now what I'm trying to do is add a new row


    remove the select listener

    select the row (should not fire select event because it has been remove)

    add the select listener



    This is my code, see below:

    Code:
    onAddMember: function(button, e)
    {
    this.getMemberStore().removeAll(false);
    this.getMemberStore().suspendAutoSync();
    this.getMemberStore().insert(0, this.getMemberModel().create());
    this.getMemberStore().resumeAutoSync();
    
    this.getMemberSearchGrid().getSelectionModel().un('select', this.onMemberSelect, this); //select listener is not being remove and console still outputs 'firing member select'
    this.getMemberSearchGrid().getSelectionModel().select(0);
    this.getMemberSearchGrid().getSelectionModel().on('select', this.onMemberSelect, this);
    
    this.showMemberEditWindow(this.getMemberSearchGrid().getSelectionModel().getSelection()[0]);
    },
    Any help is greatly appreciated

  2. You could just call suspendEvents/resumeEvents.

  3. #2
    Ext JS Premium Member
    Join Date
    Nov 2009
    Location
    St Louis,MO
    Posts
    267
    Answers
    20
    Vote Rating
    18
      0  

    Default

    You could just call suspendEvents/resumeEvents.

  4. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    61
    Answers
    3
    Vote Rating
    0
      0  

    Default

    Thanx...

    That worked great:

    Code:
    this.getMemberDependantGrid().getSelectionModel().suspendEvents(false);
    this.getMemberDependantGrid().getSelectionModel().select(0);
    this.getMemberDependantGrid().getSelectionModel().resumeEvents(false);

    Just out of curiosity; how would I be able to acheive the same thing using removeListener and addListener.

  5. #4
    Ext JS Premium Member
    Join Date
    Nov 2009
    Location
    St Louis,MO
    Posts
    267
    Answers
    20
    Vote Rating
    18
      0  

    Default

    The code you have looked ok. I know that un is REALLY picky about getting the exact same params as the on. It may be that the control does something different like wrapping the callback so that it doesn't match the function you are passing in. I'd have to check the code to be sure.

Tags for this Thread

Posting Permissions

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