1.bootStrapTable column项 支持多field,在formatter函数里想要获得field的值,用row.字段 获取
{ title:'操作', field: 'id', align: 'center', formatter:function(value,row,index){var e = '<a href="#" mce_href="#" οnclick="edit(\''+ row.id + '\')">编辑</a> ';var d = '<a href="#" mce_href="#" οnclick="del(\''+ row.id +'\')">删除</a> ';return e+d; }
2.统计表格函数:
function runningFormatter(value, row, index) {
return index;
}
function totalTextFormatter(data) {
return 'Total';
}
function totalFormatter(data) {
return data.length;
}
function sumFormatter(data) {
field = this.field;
return data.reduce(function(sum, row) {
return sum + (+row[field]);
}, 0);
}
function avgFormatter(data) {
return sumFormatter.call(this, data) / data.length;
}
3.bootstrap固定表格宽度或者自适应内容的宽度
这个可以通过colgroup来控制单元格的宽度,如果只定义部分宽度,其他的单元格会自适应的调整。
实例代码如下
<thead> <colgroup> <col></col> <col></col> <col></col> <col></col> <col></col> <col width='20%'></col> <col></col> <col></col> </colgroup> <tr> <th>用户名称</th> <th>登录方式</th> <th>联系方式</th> <th>内容</th> <th>客户端</th> <th>备注</th> <th>最后记账时间</th> <th>操作</th> </tr> </thead>