Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Multicell selection mode on grid

  1. #1
    Sencha User
    Join Date
    Oct 2009
    Location
    Ho Chi Minh, Viet Nam
    Posts
    5

    Default Multicell selection mode on grid

    Hi everybody,

    I customized class Ext.selection.CellModelView, and I can select multicell on grid by hold on Ctrl key or Shift key.
    Here my codes
    HTML Code:
    Ext.define('MyApp.MultiCellSelectionModel', {
        
        extend: 'Ext.selection.Model',
        
        alias: 'selection.cellmodel',
        
        requires: ['Ext.util.KeyNav'],
    
        enableKeyNav: true,
    
        preventWrap: false,
        
        selected: null,
    
        constructor: function(){
            
            this.addEvents(
                'deselect',
                'select'
            );
            
            this.callParent(arguments);
            
        },
    
        bindComponent: function(view) {
            
            var me = this;
            me.primaryView = view;
            me.views = me.views || [];
            me.views.push(view);
            me.bind(view.getStore(), true);
    
            view.on({
                cellmousedown: me.onMouseDown,
                refresh: me.onViewRefresh,
                scope: me
            });
    
            if (me.enableKeyNav) {
                
                me.initKeyNav(view);
                
            }
            
        },
    
        initKeyNav: function(view) {
            
            var me = this;
    
            if (!view.rendered) {
                
                view.on('render', Ext.Function.bind(me.initKeyNav, me, [view], 0), me, {single: true});
                return;
                
            }
    
            view.el.set({
                tabIndex: -1
            });
    
            me.keyNav = Ext.create('Ext.util.KeyNav', view.el, {
                up: me.onKeyUp,
                down: me.onKeyDown,
                right: me.onKeyRight,
                left: me.onKeyLeft,
                tab: me.onKeyTab,
                scope: me
            });
        },
    
        getHeaderCt: function() {
            
            return this.primaryView.headerCt;
            
        },
        
        allCellDeselect: function() {
            
            var me = this,
                i = 0,
                len = me.selected.items.length;
    
            for( ; i<len; i++){
    
                me.primaryView.onCellDeselect(me.selected.items[i].position);
    
            }
            
            me.fireEvent('deselect', me, this.selected);
            me.selected.items = [];
            
        },
    
        onKeyUp: function(e, t) {
            
            this.move('up', e);
            
        },
    
        onKeyDown: function(e, t) {
            
            this.move('down', e);
            
        },
    
        onKeyLeft: function(e, t) {
            
            this.move('left', e);
            
        },
    
        onKeyRight: function(e, t) {
            
            this.move('right', e);
            
        },
    
        move: function(dir, e) {
    
            var me = this,
                pos = me.primaryView.walkCells(me.getCurrentPosition(), dir, e, me.preventWrap),
                cell = me.view.getCellByPosition(pos);
            
            if (pos) {
                
                me.setCurrentPosition(pos);
                
            }
    
            cell.position = pos;
            
            if (e.ctrlKey && me.isSelected(cell)) {
                
                if(me.allowDeselect){
                    
                    var index = this.selected.items.indexOf(cell);
                    this.selected.items.splice(index,1);
                    me.primaryView.onCellDeselect(me.getCurrentPosition());
                    
                }
                
            } else if (e.shiftKey && me.lastSelected) {
                
                if (me.getCurrentPosition()) {
                    
                    me.allCellDeselect();
    
                }
                
                me.selectRange(cell, false);
                
            } else if (e.ctrlKey) {
                
                me.doMultiSelect(cell, true, true);
    
            } else {
                
                if (me.getCurrentPosition()) {
                    
                    me.allCellDeselect();
    
                }
                
                me.doSingleSelect(cell, true);
                
            }
            
            return pos;
            
        },
    
        getCurrentPosition: function() {
            
            return this.position;
            
        },
    
        setCurrentPosition: function(pos) {
            
            var me = this;
            this.position = pos;
            
        },
    
        onMouseDown: function(view, cell, cellIndex, record, row, rowIndex, e) {
            
            var me = this;
            
            me.setCurrentPosition({
                row: rowIndex,
                column: cellIndex
            });
            
            me.selectWithEvent(record, e );
            
        },
        
        isSelected: function(record) {
            
            record = Ext.isNumber(record) ? this.store.getAt(record) : record;
    
            if(this.selected.items == null || this.selected.items == ''){
           
                return false;
                
            }
            
            return this.selected.items.indexOf(record) !== -1;
            
        },
        
        selectWithEvent: function(record, e) {
            
            var me = this;
            
            var cell = me.view.getCellByPosition(me.getCurrentPosition());
            cell.position = me.getCurrentPosition();
            
            switch (me.selectionMode) {
            
                case 'MULTI':
                    
                    if (e.ctrlKey && me.isSelected(cell)) {
                        
                        if(me.allowDeselect){
                            
                            var index = this.selected.items.indexOf(cell);
                            this.selected.items.splice(index,1);
                            me.primaryView.onCellDeselect(me.getCurrentPosition());
                            
                        }
                        
                    } else if (e.shiftKey && me.lastSelected) {
                        
                        if (me.getCurrentPosition()) {
                            
                            me.allCellDeselect();
    
                        }
                        
                        me.selectRange(cell, false);
                        
                    } else if (e.ctrlKey) {
                        
                        me.doMultiSelect(cell, true, true);
    
                    } else {
                        
                        if (me.getCurrentPosition()) {
                            
                            me.allCellDeselect();
    
                        }
                        
                        me.doSingleSelect(cell, true);
                        
                    }
                    
                    break;
                    
                case 'SIMPLE':
                    
                    if (me.isSelected(record)) {
                        
                        me.doDeselect(record);
                        
                    } else {
                        
                        me.doSelect(record, true);
                        
                    }
                    
                    break;
                    
                case 'SINGLE':
                    
                    if (me.allowDeselect && me.isSelected(record)) {
                        
                        me.doDeselect(record);
                    
                    } else {
                        
                        me.doSelect(record, false);
                        
                    }
                    
                    break;
                    
            }
            
        },
        
        doSingleSelect: function(record, suppressEvent) {
    
            var me = this,
                changed = false,
                selected = me.selected;
            
            if (me.locked) {
                
                return;
                
            }
    
            if (me.isSelected(record)) {
                
                return;
                
            }
    
            function commit () {
                me.bulkChange = true;
                if (selected.getCount() > 0 && me.doDeselect(me.lastSelected, suppressEvent) === false) {
                    delete me.bulkChange;
                    return false;
                }
                delete me.bulkChange;
    
                me.selected.items.push(record);
                me.lastSelected = record;
                changed = true;
    
            }
    
            me.onSelectChange(record, true, suppressEvent, commit);
            me.primaryView.onCellSelect(record.position);
            
            if (changed) {
                if (!suppressEvent) {
                    me.setLastFocused(record);
                }
                me.maybeFireSelectionChange(!suppressEvent);
            }
            
            
        },
        
        doMultiSelect: function(records, keepExisting, suppressEvent) {
            
            var me = this,
                selected = me.selected,
                change = false,
                i = 0,
                len, record;
    
            if (me.locked) {
                return;
            }
    
    
            records = !Ext.isArray(records) ? [records] : records;
            len = records.length;
            if (!keepExisting && selected.getCount() > 0) {
                if (me.doDeselect(me.getSelection(), suppressEvent) === false) {
                    return;
                }
            }
    
            function commit () {
                selected.items.push(record);
                change = true;
            }
    
            for (; i < len; i++) {
                
                record = records[i];
                if (keepExisting && me.isSelected(record)) {
                    continue;
                }
                
                me.onSelectChange(record, true, suppressEvent, commit);
                me.primaryView.onCellSelect(record.position);
            }
            me.setLastFocused(record, suppressEvent);
            me.maybeFireSelectionChange(change && !suppressEvent);
            
        },
        
        selectRange : function(record, keepExisting){
            
            var me = this,
                start, end,
                x,y,xmin,ymin,xmax,ymax,
                records = [];
            
            if (me.isLocked()){
                return;
            }
            
            start = record.position;
            end = me.lastSelected.position
    
            if(start.column < end.column){
                
                xmin = start.column;
                xmax = end.column;
                
            }else{
                
                xmin = end.column;
                xmax = start.column;
                
            }
            
            if(start.row < end.row){
                
                ymin = start.row;
                ymax = end.row;
                
            }else{
                
                ymin = end.row;
                ymax = start.row;
                
            }
            
            for(x = xmin; x <= xmax; x++){
                
                for(y = ymin; y <= ymax; y++){
                    
                    var cell = me.view.getCellByPosition({row: y, column: x});
                    cell.position = {row: y, column: x};
                    me.doMultiSelect(cell, keepExisting, true);
                    
                }
                
            }
            
    
        },
        
        onSelectChange: function(record, isSelected, suppressEvent, commitFn) {
            
            var me = this,
                view = me.view,
                eventName = isSelected ? 'select' : 'deselect';
    
            if ((suppressEvent || me.fireEvent('before' + eventName, me, record)) !== false &&
                    commitFn() !== false) {
    
                if (isSelected) {
                    view.onItemSelect(record);
                } else {
                    view.onItemDeselect(record);
                }
    
                if (!suppressEvent) {
                    me.fireEvent(eventName, me, record);
                }
            }
        },
        
        onKeyTab: function(e, t) {
            var me = this,
                direction = e.shiftKey ? 'left' : 'right',
                editingPlugin = me.view.editingPlugin,
                position = me.move(direction, e);
    
            if (editingPlugin && position && me.wasEditing) {
                editingPlugin.startEditByPosition(position);
            }
            delete me.wasEditing;
        },
    
        onEditorTab: function(editingPlugin, e) {
            var me = this,
                direction = e.shiftKey ? 'left' : 'right',
                position  = me.move(direction, e);
    
            if (position) {
                editingPlugin.startEditByPosition(position);
                me.wasEditing = true;
            }
        },
    
        refresh: Ext.emptyFn,
    
        onViewRefresh: Ext.emptyFn,
    
        selectByPosition: function(position) {
            this.setCurrentPosition(position);
        }
    });
    Example:
    HTML Code:
    var grid_schedule = Ext.create('Ext.grid.Panel',{
                    ...             
                     selModel: Ext.create('MyApp.MultiCellSelectionModel',{
                            mode: 'MULTI',
                            allowDeselect: true
                     }),     
                     multiSelect: true,
                     selType: 'cellmodel',
                    listeners: {    
                    
                        cellclick: function(grid, rowIndex, columnIndex, e){
                            
                            var selected = grid_schedule.getSelectionModel().selected,
                                i = 0,
                                len = selected.items.length,
                                item,
                                currentDay = '';
    
                            for( ; i<len; i++){
    
                                item = selected.items[i];
                                currentDay += item.dom.textContent + ';';
    
                            }
                            
                        }
                  
                    }
                    ...
    });
    Though it was run but it isn't perfect yet, so i hope everybody discuss more
    Sorry about my English.

    Code was updated on 11/06/2012
    Updated on 19/06/2012: fix bug on IE8

  2. #2
    Sencha User
    Join Date
    Jan 2011
    Location
    San Juan, PR
    Posts
    84

    Default

    Love IT! nice job... i'll be using this one :-)

  3. #3

    Default bind replaced with bindStore in 4.1.x

    For use with both ExtJS 4.0.7 and 4.1.x, in bindComponent(), replace:

    Code:
           me.bind(view.getStore(), true);
    with:

    Code:
            try{
                me.bindStore(view.getStore(), true); // extjs 4.1.x             
            }catch(e){
                me.bind(view.getStore(), true); // extjs 4.0.7
            }

  4. #4
    Sencha Premium Member
    Join Date
    Apr 2010
    Posts
    6

    Default IE does not support indexOf

    for IE support replace use of indexOf() with Ext.Array.indexOf()
    http://docs.sencha.com/ext-js/4-0/#!...method-indexOf

  5. #5
    Sencha User
    Join Date
    Mar 2012
    Posts
    5

    Default

    Thank you !

  6. #6
    Sencha User
    Join Date
    Mar 2008
    Location
    San Jose, CA
    Posts
    124

    Default Updated to preserve records in store.items

    I have a version that preserves the actual records in the store.

    Initial version above was not passing me items I could use with my current app (we keep
    separate records for every cell). So I have attached each selected cell view to records such that
    I have access to both record and cell, and full MultiCellSelectionModel.ziprecords are still kept as I need in the model's selection items.

    If this is useful, please comment. Maybe it's only useful to me but thought I'd attach instead of putting code inline, since it will require a diff to see my changes..

    Also, I don't think this code works for SINGLE OR SIMPLE selection modes but maybe someone else can fix it up if they need those modes.

  7. #7
    Sencha User
    Join Date
    Apr 2013
    Posts
    7

    Default

    Hey, just want to say awesome, awesome, awesome work guys. But ...

    I have a problem with the selection. If i select a cell and after that a cell which is in the same row, the first selected cell does'nt get deselected.
    Second thing is, that if i make a selection and then right click in the grid, everything gets deselected.

    Can you point out a road map or a fix for this two 'bugs'.

    Thx in advance and greetz
    Sascha

  8. #8
    Sencha Premium Member
    Join Date
    Jun 2009
    Location
    Italy
    Posts
    19

    Default

    Since I found the same issues of Sighter,I did some fix to the UX so next unlucky guy that needs MULTY CELL SELECTION in grids (and tree grids) will spend some hour at the beach instead of fixin' code!

    This works fine for me in Ext 4.2.1

    PHP Code:

    /* MultiCellSelectionModel - extends Ext.selection.Model,*  also overrides some methods of Ext.selection.Model**  Starts with some of the code from Ext.selection.CellModel*  but supports full multiple cell selection and range selection*  while also preserving all cell records correctly. JP-*  Obtained in http://www.sencha.com/forum/showthread.php?214050-Multicell-selection-mode-on-grid&p=821190#post821190*/
    Ext.define('Ext.ux.MultiCellSelectionModel', {    extend'Ext.selection.Model',    alias'selection.cellmodel',    requires: ['Ext.util.KeyNav'],
        
    /**    * @cfg {Boolean} enableKeyNav    * Turns on/off keyboard navigation within the grid.    */    enableKeyNavtrue,
        
    /**    * @cfg {Boolean} preventWrap    * Set this configuration to true to prevent wrapping around of selection as    * a user navigates to the first or last column.    */    preventWrapfalse,
        
    selectednull,
        
    constructor: function () {
            
    this.addEvents(        /**        * @event deselect        * Fired after a cell is deselected        * @param {Ext.selection.CellModel} this        * @param {Ext.data.Model} record The record of the deselected cell        * @param {Number} row The row index deselected        * @param {Number} column The column index deselected        */            'deselect',
            
    /**        * @event select        * Fired after a cell is selected        * @param {Ext.selection.CellModel} this        * @param {Ext.data.Model} record The record of the selected cell        * @param {Number} row The row index selected        * @param {Number} column The column index selected        */            'select'        );
            
    this.callParent(arguments);
        },
        
    bindComponent: function (view) {
            var 
    me this;        me.primaryView view;        me.views me.views || [];        me.views.push(view);        //me.bind(view.getStore(), true);        me.bindStore(view.getStore(), true);  // updated for 4.1.x from 4.0
            
    view.on({            cellmousedownme.onMouseDown,            refreshme.onViewRefresh,            scopeme        });
            if (
    me.enableKeyNav) {            me.initKeyNav(view);        }    },
        
    initKeyNav: function (view) {
            var 
    me this;        if (!view.rendered) {            view.on('render'Ext.Function.bind(me.initKeyNavme, [view], 0), me, { singletrue });            return;        }
            
    view.el.set({            tabIndex: -1        });
            
    me.keyNav Ext.create('Ext.util.KeyNav'view.el, {            upme.onKeyUp,            downme.onKeyDown,            rightme.onKeyRight,            leftme.onKeyLeft,            tabme.onKeyTab,            scopeme        });    },
        
    getHeaderCt: function () {
            return 
    this.primaryView.headerCt;    },
        
    allCellDeselect: function () {
            var 
    me this,            0,            len me.selected.items.length;
            for (; 
    leni++) {            if(me.selected.items[i])                me.primaryView.onCellDeselect(me.selected.items[i].position);        }
            
    me.fireEvent('deselect'methis.selected);        me.selected.items = [];
        },
        
    onKeyUp: function (et) {
            
    this.move('up'e);    },
        
    onKeyDown: function (et) {
            
    this.move('down'e);    },
        
    onKeyLeft: function (et) {
            
    this.move('left'e);    },
        
    onKeyRight: function (et) {
            
    this.move('right'e);    },
        
    move: function (dire) {
            var 
    me this,            pos me.primaryView.walkCells(me.getCurrentPosition(), direme.preventWrap),            cell me.view.getCellByPosition(pos);
            if (
    pos) {            me.setCurrentPosition(pos);            pos.dataIndex me.primaryView.headerCt.gridDataColumns[pos.column].dataIndex        }
            
    cell.position pos;        cell.position.record me.primaryView.getRecord(cell.dom.parentNode);
            var 
    record = {                cellcell            };
            if (
    e.ctrlKey && me.isSelected(record)) {
                if (
    me.allowDeselect) {
                    var 
    index this.selected.items.indexOf(cell);                this.selected.items.splice(index1);                me.primaryView.onCellDeselect(me.getCurrentPosition());            }
            } else if (
    e.shiftKey && me.lastSelected) {
                if (
    me.getCurrentPosition()) {
                    
    me.allCellDeselect();            }
                
    me.selectRange(recordfalse);
            } else if (
    e.ctrlKey) {
                
    me.doMultiSelect(recordtruetrue);        } else {
                if (
    me.getCurrentPosition()) {
                    
    me.allCellDeselect();            }
                
    me.doSingleSelect(recordtrue);        }
            return 
    pos;    },
        
    /**    * Returns the current position in the format {row: row, column: column}    */    getCurrentPosition: function () {
            return 
    this.position;    },
        
    /**    * Sets the current position    * @param {Object} position The position to set.    */    setCurrentPosition: function (pos) {
            var 
    me this;        this.position pos;    },
        
    /**    * Set the current position based on where the user clicks.    * @private    */    onMouseDown: function (viewcellcellIndexrecordrowrowIndexe) {
            var 
    me this;        if (e.button === 0) {            me.setCurrentPosition({                rowrowIndex,                columncellIndex,                dataIndexview.headerCt.gridDataColumns[cellIndex].dataIndex            });
                
    me.selectWithEvent(recorde);        }    },
        
    isSelected: function (record) {
            
    record Ext.isNumber(record) ? this.store.getAt(record) : record;
            if (
    this.selected.items == null || this.selected.items == '') {
                return 
    false;        }
            return 
    this.selected.items.indexOf(record.cell) !== -1;    },
        
    selectWithEvent: function (recorde) {
            var 
    me thisr;
            var 
    cell me.view.getCellByPosition(me.getCurrentPosition());        cell.position me.getCurrentPosition();
            
    cell.position.record record;        = {            cellcell        }
            switch (
    me.selectionMode) {
                case 
    'MULTI':
                    if (
    e.ctrlKey && me.isSelected(r)) {
                        if (
    me.allowDeselect) {   // only delete so we can use cell                                                var index = this.selected.items.indexOf(cell);                        this.selected.items.splice(index, 1);                        me.primaryView.onCellDeselect(me.getCurrentPosition());                    }
                    
    } else if (e.shiftKey && me.lastSelected) {
                        if (
    me.getCurrentPosition()) {                        me.allCellDeselect();                    }
                        
    me.selectRange(rfalse);
                    } else if (
    e.ctrlKey) {                    me.doMultiSelect(rtruetrue);
                    } else {                    if (
    me.getCurrentPosition()) {
                            
    me.allCellDeselect();                    }
                        
    me.doSingleSelect(rtrue);                }
                    break;
                case 
    'SIMPLE':     // SIMPLE DOESN'T WORK CORRECTLY HAVE NOT ATTEMPTED TO FIX
                    
    if (me.isSelected(r)) {
                        
    me.doDeselect(r);
                    } else {
                        
    me.doSelect(rtrue);                }
                    break;
                case 
    'SINGLE':    // SINGLE DOESN'T WORK CORRECTLY HAVE NOT ATTEMPTED TO FIX, USE REGULAR CELL MODEL
                    
    if (me.allowDeselect && me.isSelected(r)) {
                        
    me.doDeselect(r);
                    } else {
                        
    me.doSelect(rfalse);                }
                    break;        }    },
        
    doSingleSelect: function (recordsuppressEvent) {
            var 
    me this,            changed false,            selected me.selected;
            if (
    me.locked) {
                return;        }
            if (
    me.isSelected(record)) {
                return;        }
            function 
    commit() {            me.bulkChange true;            if (selected.getCount() > && me.doDeselect(me.lastSelectedsuppressEvent) === false) {                delete me.bulkChange;                return false;            }            delete me.bulkChange;
                
    me.selected.items.push(record.cell);            me.lastSelected record;            changed true;        }
            
    me.onSelectChange(record.celltruesuppressEventcommit);        me.primaryView.onCellSelect(record.cell.position);
            if (
    changed) {            if (!suppressEvent) {                me.setLastFocused(record.cell);            }            me.maybeFireSelectionChange(!suppressEvent);        }    },
        
    doMultiSelect: function (recordskeepExistingsuppressEvent) {
            var 
    me this,            change false,            0,            lenrecord;        var selected me.selected;
            if (
    me.locked) {            return;        }

            
    records = !Ext.isArray(records) ? [records] : records;        len records.length;
            if (!
    keepExisting && selected.getCount() > 0) {
                if (
    me.doDeselect(me.getSelection(), suppressEvent) === false) {                return;            }        }
            function 
    commit() {
                
    selected.items.push(record.cell);    // keep items as records not cells!            change = true;        }
            
    for (; leni++) {
                
    record records[i];            if (keepExisting && me.isSelected(record)) {                continue;            }
                
    me.onSelectChange(record.celltruesuppressEventcommit);            me.primaryView.onCellSelect(record.cell.position);        }
            
    me.setLastFocused(record.cellsuppressEvent);        me.maybeFireSelectionChange(change && !suppressEvent);    },
        
    selectRange: function (recordkeepExisting) {
            var 
    me this;        var startendxyxminyminxmaxymax;        var records = [];
            if (
    me.isLocked()) {            return;        }
            
    start record.cell.position;        end me.lastSelected.cell.position
            
    if (start.column end.column) {
                
    xmin start.column;            xmax end.column;        } else {
                
    xmin end.column;            xmax start.column;        }
            if (
    start.row end.row) {
                
    ymin start.row;            ymax end.row;        } else {
                
    ymin end.row;            ymax start.row;        }
            for (
    xmin<= xmaxx++) {
                for (
    ymin<= ymaxy++) {
                    var 
    cell me.view.getCellByPosition({ rowycolumn});                cell.position = {                     rowy,                     columnx,                    dataIndexme.primaryView.headerCt.gridDataColumns[x].dataIndex,                    recordme.primaryView.getRecord(cell.dom.parentNode)                };                record.cell cell;                       // append cell to record and pass it to domultiselect                me.doMultiSelect(record, keepExisting, true);            }        }    },
        
    onSelectChange: function (recordisSelectedsuppressEventcommitFn) {
            var 
    me this;        var view me.view;        var eventName isSelected 'select' 'deselect';
            if ((
    suppressEvent || me.fireEvent('before' eventNamemerecord)) !== false && commitFn() !== false) {
                if (
    isSelected) {                view.onItemSelect(record);            } else {                view.onItemDeselect(record);            }
                if (!
    suppressEvent) {                me.fireEvent(eventNamemerecord);            }        }    },  // end onSelectChange
        
    onKeyTab: function (et) {
            var 
    me this;        var direction e.shiftKey 'left' 'right';        var editingPlugin me.view.editingPlugin;        var position me.move(directione);
            if (
    editingPlugin && position && me.wasEditing) {            editingPlugin.startEditByPosition(position);        }
            
    delete me.wasEditing;    },
        
    onEditorTab: function (editingPlugine) {
            var 
    me this;        var direction e.shiftKey 'left' 'right';        var position me.move(directione);
            if (
    position) {
                
    editingPlugin.startEditByPosition(position);            me.wasEditing true;        }    },
        
    refreshExt.emptyFn,
        
    onViewRefreshExt.emptyFn,
        
    selectByPosition: function (position) {
            
    this.setCurrentPosition(position);    }}); 
    Now the "selected.items" array contains the cells selected, with references for row, column, dataIndex and record. Everything needed for future cut/paste, get values etc.
    Have fun!

  9. #9

    Default

    Hi mrjari,
    THe code you pasted is working great for selection,
    but when I am doing grid.getSelectionModel().getSelection()
    instead of array of type (Ext.data.Model) it is returning (Ext.dom.Element)

    Can you please guide me to get the model from selection??

    Thanks

  10. #10
    Sencha Premium Member
    Join Date
    Jun 2009
    Location
    Italy
    Posts
    19

    Default

    Here is a snapshot of what I do to get all selected cells and work on 'em
    Code:
                    for (i = 0; i < grid.selModel.selected.items.length; i++) {
                        cell = grid.selModel.selected.items[i];
                        record = cell.position.record;  //here you get the record (Model)
                        
                        oldval = record.get(cell.position.dataIndex); //here you get the value
                        
                        record.set(cell.position.dataIndex, newVal);  //here you can set the new value if needed
                    }
    I hope this can help...

Page 1 of 2 12 LastLast

Posting Permissions

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