1. #1
    Sencha - Community Support Team mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    2,777
    Vote Rating
    112
    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

  2. #2
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    neat!

    any idea why it doesn't work with the checkbox column (the "Indoor?" column in your live demo) though?

  3. #3
    Sencha - Community Support Team mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    2,777
    Vote Rating
    112
    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


    Yeah, the checkbox column isn't like the other columns as it doesn't define an editor and it also doesn't fire 'afteredit' event which is what my plugin relies on.

    Though it kinda doesn't make any sense when it comes to check-columns as they only require 1 click to toggle meaning equal amount of click-work when using my plugin

    BTW, is there a way to prevent Enter key from auto-editing next cell in EditorGridPanels? I would like to turn that off when using multi-row update...

  4. #4
    Ext JS Premium Member
    Join Date
    Jan 2008
    Posts
    88
    Vote Rating
    0
    Allan is on a distinguished road

      0  

    Default


    Hi,

    does the moveEditorOnEnter option (from CheckboxSelectionModel) set to false do what you want when the enter key is pressed?

    Allan

  5. #5
    Ext User Yoris's Avatar
    Join Date
    Dec 2007
    Posts
    36
    Vote Rating
    0
    Yoris is on a distinguished road

      0  

    Default


    i believe it doesnt

  6. #6
    Ext JS Premium Member
    Join Date
    Jan 2008
    Posts
    88
    Vote Rating
    0
    Allan is on a distinguished road

      0  

    Default


    Can you explain the need for this handler assignment please?

    PHP Code:
        // Deactivate row selection by row click
        
    handleMouseDown Ext.emptyFn 
    For me, assigning the handler to the empty function disables the shift and ctrl select functionality of the selection model. Although the checkbox selection model is equivalent to a ctrl-click selection model the ability to shift select is useful.

    So, what would be the problem with allowing the standard handling of the 'handleMouseDown' event?
    Last edited by Allan; 25 Sep 2008 at 10:14 AM. Reason: Clarification of question

  7. #7
    Sencha - Community Support Team mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    2,777
    Vote Rating
    112
    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


    The emptyFn was needed for Ext versions < 2.2. The row selectionmodel functionality must have changed in Ext 2.2. With versions prior to 2.2 every row click on an editorgrid row counted as a row selection as well (meaning every time I want to enter edit mode, the clicked row will be the only one selected).

    You can remove the row for Ext 2.2!

  8. #8
    Sencha Premium Member
    Join Date
    Nov 2011
    Posts
    43
    Vote Rating
    2
    agunescu is on a distinguished road

      0  

    Default


    Is it a version of this plugin for ExtJS 4.1 ?