Bootstrop-table data table row modification, bootstrop
Bootstrop-table data row Modification
Set the attribute editable :{
Type: 'text', // The data is displayed in the text box.
Emptytext: "--", // displayed when the data is empty
Validate: function (value ){
If ($. trim (value) = ''){
Return 'cannot be blank'; // modify to display empty data
}
}
}
Set attributes when loading data in bootstrop-table in js
OnEditableSave: function (field, row, oldValue, $ el ){
$ ('# Id'). bootstrapTable ('resetview ');
Row = dataWarp (row, field); // you can write or not repackage data during editing.
$. Ajax ({
Type: "post ",
Url: path,
Data: row, // data modified in the row
DataType: 'json ',
Success: function (data, status ){
If (status = "success "){
Modal. alert ({
Msg: "edited! "
});
}
},
Error: function (){
Modal. alert ({
Msg: "editing failed! "
});
$ ('# Id'). bootstrapTable ('refresh'); // refresh after the data is loaded successfully
},
Complete: function (){
}
});
}