u012499506
小咪的农场
2017-11-16 07:39

bootstrap table 数据传递成功,就是不显示数据

  • bootstrap

bootstrap table 提示onloadsuccess 了,并且查看有数据,但是table就是不显示;
页面:




Alert
        <table id="fresh-table" class="table" data-pagination="true"
            data-show-toggle="true"
            data-showColumns="true">
            <thead>
                <tr>
                    <th data-field="id" data-checkbox="true">id</th>
                    <th data-field="username" data-sortable="true">Name</th>
                    <th data-field="phone" data-sortable="true">Salary</th>
                    <th data-field="actions" data-formatter="operateFormatter"
                        data-events="operateEvents">Actions</th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
    </div>

</div>

JS:
 $(top.hangge());

    var $table = $('#fresh-table'),
        $alertBtn = $('#alertBtn'), 
        full_screen = false,
        window_height;

    $().ready(function(){

        window_height = $(window).height();
        table_height = window_height - 20;
        $table.bootstrapTable('destroy');

        $table.bootstrapTable({
        toolbar: ".toolbar",
        url : '<%=basePath%>receiving/queryList.do', //请求后台的URL(*)
        method : 'get', //请求方式(*)
        showRefresh : true,
        search : true,
        showToggle : true,
        showColumns : true,
        pagination : true,
        striped : true,
        sortable : true,
        height : table_height,
        pageSize : 25,
        pageList : [ 25, 50, 100 ],
        formatShowingRows : function(pageFrom, pageTo, totalRows) {
        },
        formatRecordsPerPage : function(pageNumber) {
            return pageNumber + " rows visible";
        },
        icons : {
            refresh : 'fa fa-refresh',
            toggle : 'fa fa-th-list',
            columns : 'fa fa-columns',
            detailOpen : 'fa fa-plus-circle',
            detailClose : 'fa fa-minus-circle'
        },
        onLoadSuccess : function(data) {
            alert(data.rows[0].username);//这边是有数据的
        },
        onLoadError : function(status) {
            alert(status);
        }
    });

    window.operateEvents = {
        'click .like' : function(e, value, row, index) {
            alert('You click like icon, row: ' + JSON.stringify(row));
            console.log(value, row, index);
        },
        'click .edit' : function(e, value, row, index) {
            alert('You click edit icon, row: ' + JSON.stringify(row));
            console.log(value, row, index);
        },
        'click .remove' : function(e, value, row, index) {
            $table.bootstrapTable('remove', {
                field : 'id',
                values : [ row.id ]
            });

        }
    };

    $alertBtn.click(function() {
        alert("You pressed on Alert");
    });

    $(window).resize(function() {
        $table.bootstrapTable('resetView');
    });
});

function operateFormatter(value, row, index) {
    return [
            '<a rel="tooltip" title="Like" class="table-action like" href="javascript:void(0)" title="Like">',
            '<i class="fa fa-heart"></i>',
            '</a>',
            '<a rel="tooltip" title="Edit" class="table-action edit" href="javascript:void(0)" title="Edit">',
            '<i class="fa fa-edit"></i>',
            '</a>',
            '<a rel="tooltip" title="Remove" class="table-action remove" href="javascript:void(0)" title="Remove">',
            '<i class="fa fa-remove"></i>', '</a>' ].join('');
}
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答