Results 1 to 6 of 6

Thread: [2.0.2] EditorGridPanel - afteredit event not firing when leaving cell unchanged.

  1. #1

    Default [2.0.2] EditorGridPanel - afteredit event not firing when leaving cell unchanged.

    I need to know when a user has started to edit a cell, using beforeedit, and then when that user leaves the cell, afteredit. The beforeedit always fires as expected but the afteredit does not fire if the user leaves the cell without changing the value. Is this a bug or did I misunderstand the purpose of the afteredit event? I understand the value has not been modified but I need to know if the user is currently in edit mode but you will never know they left edit mode if you are waiting for the afteredit event.
    Last edited by mystix; 8 Apr 2008 at 5:47 PM. Reason: moved to 2.x Help from 2.x Bugs

  2. #2

    Default

    I guess nobody else has attempted this and thought I'd include a small example which should work on any EditorGridPanel. The beforeedit fires as expected when I double click the cell. The afteredit event only fires if the value was changed. I expected the afteredit event to fire every time the user leaves the edit mode for a cell regardless if the cell was modified or not.
    PHP Code:
        newGrid=new Ext.grid.EditorGridPanel({
                
    title:'Sample Grid',
                
    ds:myStore,
                
    cm:myColumnModel,
                
    selModel:new Ext.grid.RowSelectionModel({singleSelect:true}),
                
    frame:true,
                
    height:200,
                
    width:985,
                
    stripeRows:true,
                
    trackMouseOver:true,
                
    loadMask:true
        
    });

        
    newGrid.on({
           
    beforeedit:function(e){ console.info('beforeedit';return true; },
           
    afteredit:function(e){ console.info('afteredit');return true; }
        }); 
    I hope this is enough information for someone to help me.

  3. #3
    Ext JS Premium Member dashasalo's Avatar
    Join Date
    Feb 2010
    Location
    Newcastle Upon Tyne
    Posts
    3

    Question Same issue

    I am having the same problem. Did you find a solution?

  4. #4

    Default Use validateedit event to force afteredit to fire.

    This is how I got around the problem. I'm currently using ExtJS 3.2.1. Placing this listener on your grid should work. Good luck.

    PHP Code:
    /**
       * We always want validateedit and afteredit events to fire, so fix it so they do.
       * This allows us to have a listener on the grid to know when the user has left
       * a field after beginedit had fired.  Normally the aferedit event only gets fired
       * if the user actually made changes and clicked somewhere else on the grid.
       * Now if fires if the user clicks somewhere else like another grid.
       *
       * @param ed
       * @param value
       * @param startValue
       */
      
    onEditComplete: function(edvaluestartValue){
        
    this.editing false;
        
    this.activeEditor null;
        
    ed.un("specialkey"this.selModel.onEditorKeythis.selModel);
        var 
    ed.record;
        var 
    field this.colModel.getDataIndex(ed.col);
        
    // Setup the object to be passed to the validateedit event.
        
    var = {
          
    gridthis,
          
    recordr,
          
    fieldfield,
          
    originalValuestartValue,
          
    valuevalue,
          
    rowed.row,
          
    columned.col,
          
    cancel:false
        
    };
        if(
    this.fireEvent("validateedit"e) !== false && !e.cancel){
          
    r.set(fieldvalue);
          
    delete e.cancel;
          
    this.fireEvent("afteredit"e);
        }
        
    this.view.focusCell(ed.rowed.col);
      } 
    -- KC
    "There are only 10 types of people in the world, those who understand binary and those who don't."

  5. #5
    Ext JS Premium Member dashasalo's Avatar
    Join Date
    Feb 2010
    Location
    Newcastle Upon Tyne
    Posts
    3

    Talking yay

    Thank you!

  6. #6
    Sencha User murrah's Avatar
    Join Date
    Oct 2007
    Location
    Katoomba, Blue Mountains, west of Sydney, Australia
    Posts
    400

    Default

    Quote Originally Posted by KevinChristensen View Post
    Placing this listener on your grid should work. Good luck.
    Thanks for this. Can you be more specific about how to use this please? eg using your sample code in post #2 above.

    Thanks,
    Murray

Posting Permissions

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