Jquery easyui datagrid 怎么设置默认值和动态的改变某列的值

如题所述

定义一个变量存放正在编辑的行,通过updateRow这个方法从新执行formatter这个方法通过这个变量判断选择哪个就可以

field: 'operate',
title: '操作',
//title: $res_entry('SCB.label.status'),
width: 100,
formatter: function(value, rowData, rowIndex){
var operate = '<a href="javascript:void(0)" onclick="modify(' + rowIndex + ')">修改</a>'
if (editorRow != -1 && editorRow == rowIndex) {
operate = '<a href="javascript:void(0)" onclick="saveEdit(' + rowIndex + ')">保存</a> ' +
'<a href="javascript:void(0)" onclick="cancelEdit(' +
rowIndex +
')">取消</a>';
}
return operate;

}

/**
* 修改
*/
function modify(index){
//判断是否只有一行在修改
var num = POSStockRowTable.datagrid('getSelections');
if (editorRow == -1) {
//当没有数据编辑时则进行编辑
//打开编辑器进行编辑
POSStockRowTable.datagrid('beginEdit', index);
//将当前编辑的行号给记录在编辑的行变量中
editorRow = index;
//更新当前编辑行的内容,用于改变操作的数据 operate 列值
POSStockRowTable.datagrid('updateRow', {
index: index,
row: {
operate: ""
},
});

}
else {
//当有数据编辑时提示是否保存
$.messager.confirm('提示', '是否保存正在修改的数据', function(btn2){
//点击确定则保存,否则取消
if (btn2) {
//存放正在编辑的行号
var index = editorRow;
editorRow = -1;
POSStockRowTable.datagrid('endEdit', index);
}
});
}

}
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答