Ext JS get grid's selected row

12,601

Is is what you are looking for :

listeners:{
 click:function(){
       var grid = Ext.getCmp('grid');
       var selection= grid.getSelectionModel(); 
       items=[];
       for(i=0;i < grid.store.getCount();i++){  
          if(selection.isSelected(i)){
            items.push({ 
               "MinOperationAmount"   : grid.store.getAt(i).data.MinOperationAmount,
               "MaxOperationAmount"   : grid.store.getAt(i).data.MaxOperationAmount
             });
      }
    }
 }
}

In items array,you will be getting handle to all the selected records.Here i have pushed only two columns data.You can add other columns too.

Share:
12,601
Dimitri
Author by

Dimitri

Updated on June 04, 2022

Comments

  • Dimitri
    Dimitri almost 2 years

    On someButton click event I want to get the selected row of someGrid and Do something in event-handler dependent on that. How can I do that? I tried using

    var index = someGrid.getSelectionModel().getSelection().selectedIndex; 
    var index = someGrid.getSelectionModel().getSelection().selected;
    

    Both of this lines of code return empty objects.

    flex: 1,
                    xtype: 'grid',
                    style: 'margin: 10px 5px;',
                    store: 'CL.Store.VendorServiceLimits',
                    itemId: 'vendorServiceLimitsGrid',
                    columns: [
                        { text: Labels.Vendors.MIN_AMOUNT, dataIndex: 'MinOperationAmount', flex: 1 },
                        { text: Labels.Vendors.MAX_AMOUNT, dataIndex: 'MaxOperationAmount', flex: 1 },
                        { text: Labels.Vendors.MAX_TRANS_PER_DAY, dataIndex: 'MaxOperationsPerDay', flex: 1 },
                        { text: Labels.Vendors.OPERATION_TYPE, dataIndex: 'OperationType', flex: 1 },
                        { text: Labels.Vendors.PERIOD, dataIndex: 'Period', flex: 1 },
                        { dataIndex: 'Id', hidden: true }
                    ],