Extjs 如何得到grid中某一列的值
var simpsonsStore=Ext.create('Ext.data.Store', {
storeId : 'simpsonsStore',
fields : [ 'operation', 'stockUpId', 'stockUpName', 'specifications',
'number', 'unitPrice', 'purchasingPrice', 'tax', 'amount',
'explain' ],
data : {
'items' : [ {
'operation' : 'operation1',
'stockUpId' : 'stockUpId1',
'stockUpName' : 'stockUpName1',
'specifications' : 'specifications1',
'number' : 'number1',
'unitPrice' : 'unitPrice1',
'purchasingPrice' : 'purchasingPrice1',
'tax' : 'tax1',
'amount' : 'amount',
'explain' : 'explain'
}, {
'operation' : 'operation2',
'stockUpId' : 'stockUpId2',
'stockUpName' : 'stockUpName2',
'specifications' : 'specifications2',
'number' : 'number2',
'unitPrice' : 'unitPrice2',
'purchasingPrice' : 'purchasingPrice2',
'tax' : 'tax2',
'amount' : 'amount',
'explain' : 'explain'
}, {
'operation' : 'operation3',
'stockUpId' : 'stockUpId3',
'stockUpName' : 'stockUpName3',
'specifications' : 'specifications',
'number' : 'number',
'unitPrice' : 'unitPrice',
'purchasingPrice' : 'purchasingPrice',
'tax' : 'tax',
'amount' : 'amount',
'explain' : 'explain'
}, {
'operation' : 'operation4',
'stockUpId' : 'stockUpId4',
'stockUpName' : 'stockUpName4',
'specifications' : 'specifications',
'number' : 'number',
'unitPrice' : 'unitPrice',
'purchasingPrice' : 'purchasingPrice',
'tax' : 'tax',
'amount' : 'amount',
'explain' : 'explain'
}, {
'operation' : 'operation5',
'stockUpId' : 'stockUpId5',
'stockUpName' : 'stockUpName5',
'specifications' : 'specifications',
'number' : 'number',
'unitPrice' : 'unitPrice',
'purchasingPrice' : 'purchasingPrice',
'tax' : 'tax',
'amount' : 'amount',
'explain' : 'explain'
} ]
},
proxy : {
type : 'memory',
reader : {
type : 'json',
root : 'items'
}
}
}); var zlGrid = Ext.create('Ext.grid.Panel', {
store : Ext.data.StoreManager.lookup('simpsonsStore'),
columns : [ {
header : '操作',
dataIndex : 'operation'
}, {
header : '货存编号',
dataIndex : 'stockUpId'
}, {
header : '货存名称',
dataIndex : 'stockUpName'
}, {
header : '规格型号',
dataIndex : 'specifications'
}, {
header : '数量',
dataIndex : 'number'
}, {
header : '单价',
dataIndex : 'unitPrice'
}, {
header : '采购额',
dataIndex : 'purchasingPrice'
}, {
header : '税额',
dataIndex : 'tax'
}, {
header : '金额',
dataIndex : 'amount'
}, {
header : '说明',
dataIndex : 'explain'
} ],
height : 200,
width : '100%',
renderTo : 'zlItemGrid'
});

解决方案 »

  1.   


        var sm = Ext.grid.RowSelectionModel();
        //在grid的定义中加入:
        sm:sm
        
        //然后通过
        var record = sm.getSelected();
        var records = sm.getSelections();//返回选择的所有记录
      

  2.   

    遍历grid.getStore()  //取得grid的数据源
    var comValue;
    for(int i;i<grid.getStore().getCount();i++)
    {
       comValue+=grid.getStore().getAt(i).data.字段名+',';
    }
    所有的列的数据都取出来了,你要具体怎么使用就怎么使用。store是个好东西可以去api里面好好看看。
      

  3.   

    var values = [];
    store.each(function(item, index, count) {
        values.push(item.get('stockUpId'))
    })
      

  4.   

    撸主貌似只要某一列的值吧。
    这么弄是获取某一列值的方法。var arrs = [];
    ... ...
    columns:[{
       header:'某一列',
       renderer:function(value){//这个回到函数会将这列的所有值push进arrs里,然后就如撸主所愿了。
           arrs.push(value);     
           return value;
       }
    }]