前面不要忘记引入'editable'
idField: 'id', //主键字段名,提交表单时传递三个值name:字段名, value:修改的值, pk:主键ID
columns: [
{
field: 'weigh',
title: __('Weigh'),
editable: {
type: 'text',
url: "cate/editWeigh",
validate: function (v) {
if($.trim(v) == '') return '值不能为空';
if(!$.isNumeric(v)) return '值只能为数字';
if(v<0 || v%1!==0) return '值必需为正整数';
},
success: function(response, newValue) {
console.log("====ok=====",response, newValue);
let that = this;
if(response.code==1){
//更新内存对象值,如果该字段是排序字段,页面会重新排序
table.bootstrapTable('updateCell', {
index: $(that).closest("tr").data('index'), //行索引
field: 'weigh', //列名
value: newValue //cell值
});
}else{
return response.msg;
}
},
error: function(response, newValue){
console.log("====error=====",response, newValue);
return "请求失败";
}
}
}
]