1. #1
    Sencha User
    Join Date
    Feb 2013
    Location
    NZ
    Posts
    66
    Answers
    5
    Vote Rating
    0
    mazhar.shaikh is on a distinguished road

      0  

    Default Answered: Saving multiple rows selected using a checkbox selection model at once.

    Answered: Saving multiple rows selected using a checkbox selection model at once.


    Hello,


    I have a grid that uses Checkbox selection model. Under the grid, I have a Save button that has to save all the currently selected rows from the grid to my store. I know how to save a single row, but not sure about
    how to save multiple rows at once that are currently selected using checkbox selection model.
    Can someone guide me on how to achieve that.

    Thanks

    Code for controller:

    Code:
    // Get the selected item first
    var grid = Ext.getCmp('titleSearchResultsGridPanel');
    var selection = grid.getSelectionModel().getSelection();
    if (selection.length > 0){
     var itemStore = Ext.getStore('GeneratePicklist');
        itemStore.proxy.url = MasterDataManager.globals.url + "Items/";
        //itemStore.update(active);
        itemStore.sync();           
    
    }
    else{
        //TODO: no items selected
    }

    Code for Store

    Code:
    Ext.define('PickList.store.GeneratePicklist', {
        extend: 'Ext.data.Store',
    
    
        requires: [
            'PickList.model.GeneratePicklist'
        ],
    
    
        constructor: function(cfg) {
            var me = this;
            cfg = cfg || {};
            me.callParent([Ext.apply({
                autoLoad: false,
                remoteFilter: true,
                remoteSort: true,
                storeId: 'generatePicklist',
                model: 'PickList.model.GeneratePicklist',
                pageSize: 50,
                proxy: {
                    type: 'rest',
                    simpleSortMode: true,
                    headers: {
                        Accept: 'application/json',
                        'Content-Type': 'application/json'
                    },
                    reader: {
                        type: 'json',
                        idProperty: 'isbn',
                        root: 'Lines',
                        totalProperty: 'TotalOrders'
                    },
                    writer: {
                        type: 'json'
                    }
                }
            }, cfg)]);
        }
    });
    Code for the Grid View

    Code:
    {                            xtype: 'form',
                                id: 'reviewPicklistForm',
                                layout: {
                                    type: 'auto'
                                },
                                title: '',
                                items: [
                                    {
                                        xtype: 'gridpanel',
                                        height: 364,
                                        id: 'reviewPicklistGrid',
                                        margin: '0 0 10',
                                        width: 1091,
                                        title: '',
                                        store: 'GeneratePicklist',
                                        viewConfig: {
                                            id: 'reviewPicklistGridview'
                                        },
                                        selModel: Ext.create('Ext.selection.CheckboxModel', {
    
    
                                        }),
                                        columns: [
                                            {
                                                xtype: 'gridcolumn',
                                                dataIndex: 'isbn',
                                                text: 'ISBN'
                                            },
                                            {
                                                xtype: 'gridcolumn',
                                                width: 176,
                                                dataIndex: 'titleDescription',
                                                text: 'Title'
                                            },
                                            {
                                                xtype: 'gridcolumn',
                                                dataIndex: 'author',
                                                text: 'Author'
                                            },
                                            {
                                                xtype: 'gridcolumn',
                                                width: 82,
                                                dataIndex: 'format',
                                                text: 'Format'
                                            },
                                            {
                                                xtype: 'numbercolumn',
                                                width: 44,
                                                dataIndex: 'quantity',
                                                text: 'Qty',
                                                format: '0,000'
                                            },
                                            {
                                                xtype: 'numbercolumn',
                                                width: 79,
                                                dataIndex: 'webOrderNumber',
                                                text: 'Web Order #',
                                                format: '0000'
                                            },
                                            {
                                                xtype: 'gridcolumn',
                                                width: 66,
                                                dataIndex: 'floor',
                                                text: 'Floor'
                                            },
                                            {
                                                xtype: 'gridcolumn',
                                                dataIndex: 'category',
                                                text: 'Category'
                                            },
                                            {
                                                xtype: 'numbercolumn',
                                                width: 47,
                                                dataIndex: 'stockOnHand',
                                                text: 'SOH',
                                                format: '0000'
                                            },
                                            {
                                                xtype: 'datecolumn',
                                                width: 84,
                                                dataIndex: 'lastReceipt',
                                                text: 'Last Receipt',
                                                format: 'd/m/Y'
                                            },
                                            {
                                                xtype: 'numbercolumn',
                                                width: 95,
                                                dataIndex: 'receiptQty',
                                                text: 'Receipt Qty',
                                                format: '0,000'
                                            },
                                            {
                                                xtype: 'booleancolumn',
                                                dataIndex: 'isParked',
                                                flex: 1,
                                                text: 'Park',
                                                falseText: 'No',
                                                trueText: 'Yes'
                                            }
                                        ],
                                        dockedItems: [
                                            {
                                                xtype: 'pagingtoolbar',
                                                dock: 'bottom',
                                                width: 360,
                                                displayInfo: true,
                                                store: 'GeneratePicklist'
                                            }
                                        ]
                                    },
                                    {
                                        xtype: 'textfield',
                                        id: 'totalTitlesReviewTextbox',
                                        margin: '0 0 5',
                                        width: 208,
                                        readOnly: true,
                                        fieldLabel: 'Total Number of Titles',
                                        labelWidth: 135
                                    },
                                    {
                                        xtype: 'textfield',
                                        id: 'totalOrdersReviewTextbox',
                                        margin: '0 0 10',
                                        width: 208,
                                        readOnly: true,
                                        fieldLabel: 'Total Number of Orders',
                                        labelWidth: 135
                                    }
                                ],
                                dockedItems: [
                                    {
                                        xtype: 'toolbar',
                                        dock: 'bottom',
                                        height: 29,
                                        items: [
                                            {
                                                xtype: 'button',
                                                id: 'selectAllNewPicklistButton',
                                                text: 'Select All'
                                            },
                                            {
                                                xtype: 'button',
                                                id: 'clearAllNewPicklistButton',
                                                text: 'Clear All'
                                            },
                                            {
                                                width: 364
                                            },
                                            {
                                                xtype: 'button',
                                                id: 'printReviewPicklistButton',
                                                text: 'Print Picklist'
                                            }
                                        ]
                                    }
                                ]
                            }

  2. I achieved it using
    BATCHACTIONS: true
    config on the proxy

    Code:
    Ext.define('MyApp.store.S1', {
        extend: 'Ext.data.Store',
    
    
        requires: [
            'MyApp.model.S1'
        ],
    
    
        constructor: function(cfg) {
            var me = this;
            cfg = cfg || {};
            me.callParent([Ext.apply({
                autoLoad: false,
                storeId: 's1',
                model: 'MyApp.model.S1',
                proxy: {
                    type: 'rest',
                    batchActions: true,
                    simpleSortMode: true,
                    timeout: 120000,
                    headers: {
                        Accept: 'application/json',
                        'Content-Type': 'application/json'
                    },
                    reader: {
                        type: 'json',
                        root: 'Lines',
                        totalProperty: 'TotalRecords'
                    },
                    writer: {
                        type: 'json'
                    },
                    listeners: {
                        exception: {
                            fn: me.onRestproxyException,
                            scope: me
                        }
                    }
                }
            }, cfg)]);
        },

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,704
    Answers
    3356
    Vote Rating
    750
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    What do you mean save? What are you doing or want to do when the save button is click?

    Are you adding records to the store and when you press save you want only the selected rows to be sent and in one request?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

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

  4. #3
    Sencha User
    Join Date
    Feb 2013
    Location
    NZ
    Posts
    66
    Answers
    5
    Vote Rating
    0
    mazhar.shaikh is on a distinguished road

      0  

    Default


    I achieved it using
    BATCHACTIONS: true
    config on the proxy

    Code:
    Ext.define('MyApp.store.S1', {
        extend: 'Ext.data.Store',
    
    
        requires: [
            'MyApp.model.S1'
        ],
    
    
        constructor: function(cfg) {
            var me = this;
            cfg = cfg || {};
            me.callParent([Ext.apply({
                autoLoad: false,
                storeId: 's1',
                model: 'MyApp.model.S1',
                proxy: {
                    type: 'rest',
                    batchActions: true,
                    simpleSortMode: true,
                    timeout: 120000,
                    headers: {
                        Accept: 'application/json',
                        'Content-Type': 'application/json'
                    },
                    reader: {
                        type: 'json',
                        root: 'Lines',
                        totalProperty: 'TotalRecords'
                    },
                    writer: {
                        type: 'json'
                    },
                    listeners: {
                        exception: {
                            fn: me.onRestproxyException,
                            scope: me
                        }
                    }
                }
            }, cfg)]);
        },

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar