我在grid的行中有一个删除链接,想点一下链接把这行删除掉,但是实现不了,希望大家可以指点下
var grid = new Ext.grid.GridPanel({
ds: ds,
cm: cm,
height:h,
tbar: [{
text: ' 新增行',
iconCls: 'bmenu10',
handler : function(){
var p = new newcm({
id: "<a href='#'>[删除]</a>",
goodsNo: i=++i,
goodsName: '',
batch: '',
batch: '',
goodsType: '',
specification: '',
num: ''
});
ds.insert(0, p);
}
},{
xtype: "tbseparator"
},{
text:' 删除所有行',
iconCls:'bmenu7',
handler:''
}],
bbar: [{
xtype : 'label',
text : '合计:'
},{
xtype : "tbfill"
},{
xtype : "label",
text : "数量:"
},{
xtype : "label",
id : "totnum",
text : ""
}],
loadMask:{msg:'正在载入数据,请稍等...'}
});
grid.on('click', function(e) {
var col = e.getTarget('.deleteCol');
if (col) {
Ext.MessageBox.confirm('确认', '你确认要删除这行吗?', function(btn){
if(btn=='yes'){
var sm = grid.getSelectionModel();
var record = sm.getSelected(); //执行到这里报错
ds.remove(record);
}
});
}
}, grid);
看[url]http://atian25.iteye.com/blog/414248[/url]
用"5.4 如何为每行记录都添加一个操作列"中的方法
listeners : {
'cellclick' : function(grid, rowIndex, columnIndex, e) {
if (columnIndex == 3) {
var record = grid.getStore().getAt(rowIndex);
grid.getStore().remove(record);
}
confirm回调函数的作用域问题吧.
你看下var sm = grid.getSelectionModel(); sm是不是null
报啥错,firebug