前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Bootstrap Table -detailView和detailFilter的使用

Bootstrap Table -detailView和detailFilter的使用

作者头像
tianyawhl
发布2019-10-24 15:18:57
2.5K0
发布2019-10-24 15:18:57
举报
文章被收录于专栏:前端之攻略

查看表格

detailFilter 属性:data-detail-filter Type:Function Default:function(index,row){ return true}

detailView 属性:data-detail-view Type:Boolean Default:false

代码语言:javascript
复制
<table id="table" data-toggle="table" data-height="460" data-detail-view="true" data-detail-formatter="detailFormatter" data-detail-filter="detailFilter">
    <thead>
        <tr>
            <th data-field="id">ID</th>
            <th data-field="name">Item Name</th>
            <th data-field="price">Item Price</th>
        </tr>
    </thead>
</table>
代码语言:javascript
复制
<script>
console.log(data)
$("#table").bootstrapTable({ data: data })

function detailFormatter(index, row) {
    //var html=[];
    //$.each(row.children,function(key,value){
    //html.push('<p> key is '+key+'</p>')
    //})
    //return html.join("")
    var html = `<ul class="list-unstyled">
        <li style="float:left;margin-right:20px;"><b>name</b>:${row.children["child-name"]}</li>
        <li style="float:left;margin-right:20px;"><b>price</b>:${row.children["child-price"]}</li>
        <li style="float:left;margin-right:20px;"><b>amount</b>:${row.children["child-amount"]}</li>
        </ul>`
    return html;
}

function detailFilter(index, row) {
    return row.children
    //return index % 2 === 0
}
</script>

(adsbygoogle = window.adsbygoogle || []).push({});

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档