bootstrap table load属性

工作中用到$("#id").bootstraptable('load',data),注意:

1、data数据必须为json格式的返回,或者说返回的msg你需要转换成对象才能加载。

Js代码:

      success(res){
         var lookDetailrows = [];
         $.each(res.data[0].lookDetailMembers,function(index,value){
               if (!isEmptyObject(value)){
                     var lookDetailrow = {};
                     lookDetailrow.memberId = value.memberId;
                     lookDetailrow.memberName = value.memberName;
                     lookDetailrows.push(lookDetailrow);
                }
          });
        $('#minionSelfInfoDetail').bootstrapTable('load',lookDetailrows);

}

HTML代码:

<table id="minionSelfInfoDetail" class="table table-hover table-striped text-nowrap" data-toolbar="#toolbarminionSelfInfoDetail"  data-toggle="table" data-search="true" data-side-pagination="client">
                    <thead>
                    <tr class="info">
                        <th data-field="memberId" data-visible="false">员工号th>
                        <th data-field="memberName" >员工姓名th>
                    tr>
                    thead>
                    <tbody id="tbMain">
                    tbody>
                table>

注意:data-toggle="table"必须存在,不然load依然加载不了。

转载于:https://www.cnblogs.com/CherishZeng/p/11097668.html

你可能感兴趣的:(bootstrap table load属性)