初始化表格时,序号自增实现方法:
$("#table-list-webhoo").bootstrapTable({
......... //省略了相应的参数配置
columns : [ { //序号自增实现方法
title : '序号',
field : 'xh',
formatter: function (value, row, index) {
return index+1;
}
},{
title : '商品名称',
field : 'goods_name',
}, {
title : '编码',
field : 'code',
},
..........
,{
title : '操作',
field : 'opt',
formatter: function () {
return '\
删除\
}
}]
});
表格数据动态加载和追加的序号自增实现方法(append是追加数据,load是加载数据):
$("#table-list-webhoo").bootstrapTable('append', [{
xh:function (value, row, index) {
return index+1;
},
goods_name:dataGoods.goodsName,
code:dataGoods.goodsCode,
goods_spec:dataGoods.goodsSpec,
unit:"件",
sale_price:dataGoods.salePrice,
sale_money:dataGoods.salePrice,
goods_count:1,
goods_money:dataGoods.salePrice,
opt:function () {
return '\
删除\
}
}]);