PDA

View Full Version : Ext.ux.grid.MultiCellSelectionModel



zigi
15 Feb 2008, 4:48 AM
Hi guys,

I've done an initial implementation of an SelectionModel which allows to perform Excel-like Multi-Cell Selection. It certainly has serveral rough edges and bugs and is neither performance optimized nor cross-browser tested (only ff2 atm).

I thought it might be usefull for someone anyway.

Usage:


var grid = new Ext.grid.GridPanel({
store: store,
columns: [
{id:'company',header: "Company", width: 160, sortable: true, dataIndex: 'company'},
{header: "Price", width: 75, sortable: true, renderer: 'usMoney', dataIndex: 'price'},
{header: "Change", width: 75, sortable: true, renderer: change, dataIndex: 'change'},
{header: "% Change", width: 75, sortable: true, renderer: pctChange, dataIndex: 'pctChange'},
{header: "Last Updated", width: 85, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
],
height:350,
width:600,
title:'Array Grid',
sm: new Ext.ux.grid.MultiCellSelectionModel()
});


If someone is interested, I can explain the few config options...

Feedback is welcome ;)

Demo: http://codehaus.org/~ziegfried/multiselectdemo/

Cheers, sigi

Animal
15 Feb 2008, 5:17 AM
Nice!

mystix
15 Feb 2008, 7:09 AM
Very nice! =D>

DigitalSkyline
15 Feb 2008, 3:21 PM
Cool. Would be very nice if you could ctrl-c and paste these comma delimited "cells"!

wm003
17 Feb 2008, 7:14 AM
Very nice and useful. Thanks for sharing.;)

NoahK17
1 May 2008, 9:03 AM
What can I say... this works perfectly Zigi :)

Thanks!!

ECU
6 Aug 2008, 1:59 AM
Hi,

Thanks for this nice extension but there are somes bugs with the 2.2 version of ExtJS:

- once we click on a cell, all cells become blue on mouseover,
- we cannot have multiples cells selected.

By any chance, do you plan to fix them for this version ?

zigi
12 Aug 2008, 5:50 AM
Hi,

well, wasn't hard to fix. I've done it on my demo. You can try it for your self: http://codehaus.org/~ziegfried/multiselectdemo/index.html?v2

I've quick-tested it in FF3, Safari and IE7.

You can download it here: http://codehaus.org/~ziegfried/multiselectdemo/Ext.ux.MultiCellSelectionModel.js

Cheers, Sigi

ECU
12 Aug 2008, 8:54 AM
Hi,

Thanks a lot, you saved my life :-)

It works fine with IE6, IE7, FireFox 2

Thanks again.

superDuke
20 Aug 2008, 5:40 AM
Cool...I like it a lot. Any plans for a selectAll()..or selectRow() ?

andreros
12 Mar 2009, 7:17 AM
Hello Zigi,

first of all, very nice work. It's being really useful for me ;) One remark: I'm using your MultiCellSelectionModel on an EditorGrid (from ExtJS 2.1), and when I use my keyboard to edit a cell (pressing enter) and then do the same for leaving the cell (after editing, pressing enter again), the following error pops out: E.fireFn is undefined (I checked this with firebug).

The resolution for this problem is the following. Simply add this code snippet to your extension code:



onEditorKey : function(field, e){
var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
ed.completeEdit();
var col = this.getSelections().items[0].col;
var row = this.getSelections().items[0].row;
this.grid.getView().onCellSelect(row,col);
}
Hope to have spared anyone some time and mind puzzling ;)