Extjs 如何得到grid中某一列的值

Mable 2012-05-24 10:46:00
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'
});
...全文
2303 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
jisuanjizhuan 2013-10-28
  • 打赏
  • 举报
回复
如果要是获取同一行的某列值呢?
程序媛小李 2013-05-22
  • 打赏
  • 举报
回复
引用 5 楼 ckk521 的回复:
撸主貌似只要某一列的值吧。 这么弄是获取某一列值的方法。

var arrs = [];
... ...
columns:[{
   header:'某一列',
   renderer:function(value){//这个回到函数会将这列的所有值push进arrs里,然后就如撸主所愿了。
       arrs.push(value);     
       return value;
   }
}]
这个不错
葫芦八娃 2013-05-21
  • 打赏
  • 举报
回复
撸主貌似只要某一列的值吧。 这么弄是获取某一列值的方法。

var arrs = [];
... ...
columns:[{
   header:'某一列',
   renderer:function(value){//这个回到函数会将这列的所有值push进arrs里,然后就如撸主所愿了。
       arrs.push(value);     
       return value;
   }
}]
NANU-NANA 2013-05-21
  • 打赏
  • 举报
回复
var values = []; store.each(function(item, index, count) { values.push(item.get('stockUpId')) })
zhangdaowu5 2013-05-21
  • 打赏
  • 举报
回复
遍历 grid.getStore() //取得grid的数据源 var comValue; for(int i;i<grid.getStore().getCount();i++) { comValue+=grid.getStore().getAt(i).data.字段名+','; } 所有的列的数据都取出来了,你要具体怎么使用就怎么使用。store是个好东西可以去api里面好好看看。
丰常青 2012-05-24
  • 打赏
  • 举报
回复

var sm = Ext.grid.RowSelectionModel();
//在grid的定义中加入:
sm:sm

//然后通过
var record = sm.getSelected();
var records = sm.getSelections();//返回选择的所有记录
Mable 2012-05-24
  • 打赏
  • 举报
回复
我是要得到某一列的值呢 就是那一列的所有值
不是所选中的某一列或者某一行

87,968

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧