easyui行編輯2

createDatagrid:function(){
var opts = {
datagridId:'datagrid-cost',

//勾選複選框開啓行編輯,需結束本行編輯後再勾選下一行,如果未關閉上一行的行編輯,直接勾選下一行的複選框,上一行的保存刷新後會取消下一行的oncheck
onCheck:function(index,row){
if (mainOptains.endEditing()){//返回true則表示可以編輯(editIndex爲undefined)
$(this).datagrid('beginEdit', index);//開啓行編輯框
editIndex = index;
} else {
$('#datagrid-cost').datagrid('selectRow', editIndex);//選中索引爲editIndex的行
}
//$(this).datagrid('beginEdit', index);//開啓行編輯框(如果不點擊關閉,開啓另一行編輯框時,上一行不會自動關閉)

},
onClickCell:function(index, field, value){
$(this).datagrid('endEdit', index);//關閉行編輯框
},
onAfterEdit:function(index, row, changes){//獲取行編輯數據並動態計算
/*$('#datagrid-cost').datagrid('updateRow',{//可根據編輯的字段計算其他字段的值
index: index,
row: {
costTotal: changes.factCostAmount*1.2
}
});*/
$.ajax({//將本次實收金額傳到後臺  
    url:Config.sysUrl + '/fyMain/saveFactAmount',
    data:row,
    type:'post',  
    dataType:'json',  
success: function(result){
if(result.success){
//$.messager.alert('提示',result.msg);
$('#datagrid-cost').datagrid('reload');
}
}   
});

}

};
_createDatagrid(opts);

},


//結束行編輯
endEditing:function(){
//如果沒有開啓編輯的行,則可以編輯
if(editIndex == undefined){
return true;
}
//如果editIndex不等於undefined(editIndex已開啓行編輯狀態),則關閉當前行編輯狀態
if($("#datagrid-cost").datagrid('validateRow',editIndex)){
$("#datagrid-cost").datagrid('endEdit',editIndex);
editIndex =  undefined;
return true;
}else{
return false;
}
},

發佈了19 篇原創文章 · 獲贊 11 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章