bootstrap-table 数据表格行内修改

时间:2021-12-29 06:48:39

bootstrap-table 数据行内修改
js中设置列的属性 editable : {
type : 'text',//数据显示在文本框内
emptytext : "--",//数据为空时显示
validate : function(value) {
if ($.trim(value) == '') {
return '不能为空';//修改是数据为空 显示
}
}
}
js中设置bootstrap-table加载数据时属性
onEditableSave : function(field, row, oldValue, $el) {
$('#id’).bootstrapTable('resetView');
row = dataWarp(row, field);// 编辑时重新包装数据 可写可不写
$.ajax({
type : "post",
url : 路径,
data : row,//行内修改后的数据
dataType : 'JSON',
success : function(data, status) {
if (status == "success") {
Modal.alert({
msg : "编辑成功!"
});
}
},
error : function() {
Modal.alert({
msg : "编辑失败!"
});
$('#id’).bootstrapTable('refresh');// 数据加载成功后刷新

},
complete : function() {

}

});
}