bootStrapTable 心得 更新···


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>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值