easyui 行内编辑 autoSave失效 的解决方法
贺英悟
2023-12-01
editRow: function(jq, index){
return jq.each(function(){
var dg = $(this);
var opts = $.data(this, 'edatagrid').options;
var editIndex = opts.editIndex;
if (editIndex != index){
if (dg.datagrid('validateRow', editIndex)){
if (editIndex>=0){
if (opts.onBeforeSave.call(this, editIndex) == false) {
setTimeout(function(){
dg.datagrid('selectRow', editIndex);
},0);
return;
}
}
//”jquery.edatagrid.js“文件 添加以下四行代码完美解决问题
if(opts.autoSave){
dg.datagrid('endEdit', editIndex);
}if(!opts.autoSave){
dg.datagrid('refreshRow',editIndex);
}
dg.datagrid('beginEdit', index);
opts.editIndex = index;
if (currTarget != this && $(currTarget).length){
$(currTarget).edatagrid('saveRow');
currTarget = undefined;
}
if (opts.autoSave){
currTarget = this;
}
var rows = dg.datagrid('getRows');
opts.onEdit.call(this, index, rows[index]);
} else {
setTimeout(function(){
dg.datagrid('selectRow', editIndex);
}, 0);
}
}
});
},