Threaded View

  1. #1
    Sencha - Community Support Team mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    2,761
    Vote Rating
    108
    mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all

      0  

    Default Ext.ux.MultiRowUpdateSelectionModel

    Ext.ux.MultiRowUpdateSelectionModel


    A client of mine wanted multi-row update for a large grid where he often updated many rows with the same values. Select by checking rows in the selection column, then any change to an editable field will propagate to the selected records.

    Live example

    Code:
    Ext.namespace('Ext.ux');
    
    Ext.ux.MultiRowUpdateSelectionModel = Ext.extend(Ext.grid.CheckboxSelectionModel, {
        initEvents : function(){
            Ext.ux.MultiRowUpdateSelectionModel.superclass.initEvents.call(this);
            this.grid.on('afteredit', function(editEvent) {
              if (this.grid.selModel.selections.getCount() > 0)
              {
                this.grid.selModel.selections.each(
    	            function(rec) {
    	              if (rec !== editEvent.record)
    	              {
    	                rec.set(editEvent.field, editEvent.value);
    	              }
    	          });
    	        }
            }, this);
        }
    });
    If using this with Ext versions < 2.2, you might want to add the code below to stop the edit click to act as a row selection.

    Code:
        // Deactivate row selection by row click
        handleMouseDown : Ext.emptyFn
    Last edited by mankz; 25 Sep 2008 at 10:28 AM. Reason: Updated for Ext 2.2