//
var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
clicksToMoveEditor: 1,
saveBtnText: '更新',
cancelBtnText: '取消',
errorSummary :false,
autoCancel: true,
cancelEdit:function(grid) {
if (this.editing) {
this.getEditor().cancelEdit();
var record=this.context.record;
if(typeof (record.data.Id) == 'undefined'){
var grid=this.context.grid;
var items=grid.getSelectionModel().getSelection();
Ext.each(items,function(item){
store.remove(item);
})
}
}
}
});
plugins: [rowEditing],
listeners:{
"edit":function(editor,e){
//新增
if(typeof (e.record.data.Id) == 'undefined'){
Ext.popup.msg(e.record.data.RoleName);
Ext.popup.msg('新增成功');
}//修改
else{
Ext.popup.msg(e.record.data.RoleName);
Ext.popup.msg('修改成功');
Ext.getCmp('pagebar').doRefresh();
}
}
}
本文介绍了如何在ExtJS4.1中使用RowEditing插件时,避免在取消编辑时自动删除新增行。通过监听编辑事件,判断记录是否存在Id字段来区分新增还是修改操作。对于新增操作,显示成功消息;对于修改操作,显示修改成功消息并刷新页面。

1168

被折叠的 条评论
为什么被折叠?



