1. #1
    Sencha User
    Join Date
    Jan 2013
    Posts
    33
    Vote Rating
    1
    AssetWorks is on a distinguished road

      0  

    Default grid to grid buttons

    grid to grid buttons


    Okay so I have been looking for something like itemselector but with grids. so I created my own control that can be placed between two grids and it will take the selected records and place add/remove them to the other grid.

    here it is.

    Code:
    Ext.define('App.view.controls.CamGridToGridBtns', {
        extend: 'Ext.container.ButtonGroup',
        alias: 'widget.gridtogridbtns',
        columns:1,
        height: 300,
        width:28,
        margin: '5 0 5 0',
        items: [{
            margin: '120 0 0 0',
            iconCls: 'x-tbar-page-prev',
            handler: function (btn) {
                var me = this.up('container');
                var grid = me.next();
                selected = grid.getView().getSelectionModel().getSelection();
                me.moveRec(false, selected);
            }
        },{
            margin: '0 0 130 0',
            iconCls: 'x-tbar-page-next',
            handler: function (btn) {
                var me = this.up('container');
                var grid = me.prev();
                selected = grid.getView().getSelectionModel().getSelection();
                me.moveRec(true, selected);
            }
        }],
    
    
        moveRec: function (add, recs) {
            var me = this,
            fromGrid = me.prev(),
            toGrid = me.next(),
            fromStore = add ? fromGrid.store : toGrid.store,
            toStore = add ? toGrid.store : fromGrid.store;
            toStore.add(recs);
            fromStore.remove(recs);
        }
    });
    HOW TO USE IT:
    Code:
    ...
    {xtype: 'grid', itemId: 'grid1',columns:[{text:'Name', dataIndex:'Name'},{text:'Age', dataIndex:'Age'}]},
    {xtype: 'gridtogridbtns'},//<---use it in between two grids
    {xtype: 'grid', itemId: 'grid2', columns:[{text:'Name', dataIndex:'Name'},{text:'Age', dataIndex:'Age'}]}
    if you want to improve on in anyway feel free to hack at it.
    or even if someone has made a better one already let me know

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,582
    Vote Rating
    434
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Thanks for posting how you solved your need.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

Tags for this Thread