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依然加载不了。

posted @ 2019-06-27 16:07  十月要努力丫  阅读(5540)  评论(0编辑  收藏  举报