原文:https://blog.csdn.net/a116475939/article/details/88527597
1.在bootstrap-table.js中添加
BootstrapTable.prototype.getRowByIndex = function (index) {
if((index * 1+1)>this.options.data.length){
throw new Error("Unknown method: 没有当前序号!");
}
return this.options.data[index * 1];
};
BootstrapTable.prototype.removeByIndex = function (index) {
var len = this.options.data.length,
row = this.getRowByIndex(index);
if (row) {
this.options.data.splice(this.options.data.indexOf(row), 1);
}
if (len === this.options.data.length) {
return;
}
this.initSearch();
this.initPagination();
this.initBody(true);
};
2.在var allowedMethods =[.....]添加
'getRowByIndex', 'removeByIndex'
3.使用
$table.bootstrapTable('removeByIndex',0);//删除序号为0的数据
$table.bootstrapTable('getRowByIndex',0);//获取序号为0的数据