Implementation code of bootstrap table data table in line modification

  • 2021-07-21 06:02:26
  • OfStack

Set the column property editable in js:


{
type : 'text',// Data is displayed in a text box 
emptytext : "--",// Display when data is empty 
validate : function(value) {
if ($.trim(value) == '') {
return ' Cannot be empty ';// Modified is that the data is empty   Display 
}
}
}

Setting bootstrop-table Load Data Properties in js


onEditableSave : function(field, row, oldValue, $el) {
$('#id').bootstrapTable('resetView');
row = dataWarp(row, field);//  Rewrapping data when editing   You can write or not 
$.ajax({
type : "post",
url :  Path ,
data : row,// Modified data in a row 
dataType : 'JSON',
success : function(data, status) {
if (status == "success") {
Modal.alert({
msg : " Successful editing! "
});
}
},
error : function() {
Modal.alert({
msg : " Editing failed! "
});
$('#id').bootstrapTable('refresh');//  Refresh after successful data loading 
},
complete : function() {
}
});
}

Related articles: