PDA

View Full Version : Ext.ux.MultiRowUpdateSelectionModel



mankz
21 Jul 2008, 12:01 PM
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 (http://www.mankz.com/ext/examples/grid/edit-grid.html)


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.



// Deactivate row selection by row click
handleMouseDown : Ext.emptyFn

mystix
21 Jul 2008, 12:13 PM
neat!

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

mankz
21 Jul 2008, 9:51 PM
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...

Allan
24 Sep 2008, 7:11 AM
Hi,

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

Allan

Yoris
24 Sep 2008, 8:21 AM
i believe it doesnt

Allan
25 Sep 2008, 9:59 AM
Can you explain the need for this handler assignment please?



// 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?

mankz
25 Sep 2008, 10:26 AM
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!

agunescu
6 Dec 2012, 6:08 AM
Is it a version of this plugin for ExtJS 4.1 ?