【问题标题】:Client side pagination not showing with Smart TableSmart Table 未显示客户端分页
【发布时间】:2015-10-02 21:52:33
【问题描述】:

问题

数据异步加载并正确显示,但不出现分页。如果你能提供帮助,谢谢。

HTML

<table st-safe-src="update" st-table="displayedItemList" class="table table-striped table-bordered">
    <thead>
        <tr>
            <th>Field1</th>
            <th>Field2</th>
        </tr>
    </thead>
    <tbody>
        <tr ng-repeat="item in displayedItemList">
            <td>{{item.Field1}}</td>
            <td>{{item.Field2}}</td>
        </tr>
    </tbody>
    <tfoot>
        <tr>
            <td colspan="2" class="text-center">
                <div st-pagination="" st-items-by-page="10" st-displayed-pages="7"></div>
            </td>
        </tr>
    </tfoot>
</table>

JavaScript

    $scope.itemList = [];
    $scope.displayedItemList = [];
    $scope.update = 0;

    $scope.initialize = function ()
    {
        var d = new $.Deferred();

        itemService.getItems().then(function (data) {
            $scope.itemList = data;
            $scope.displayedItemList = [].concat($scope.itemList);
            $scope.update++;
            d.resolve();
        });

        return d;
    }

尝试了替代方案

...同样的结果。

    <table st-safe-src="itemList" ...

【问题讨论】:

  • 如果您的数据集中只有一页,则不会显示分页。 itemList 有多少项?
  • 43 项。我认为问题出在异步方面。但是我从 Smart Table 切换回 Angular UI Grid,因为我的一位同事已经有了草稿代码(并且也不显示分页)。

标签: javascript html angularjs html-table smart-table


【解决方案1】:

在控制器中,需要填写st-safe-src(更新),而不是displayedItemList. 我的意思是,例如

$scope.update = $scope.itemList; 

【讨论】:

    猜你喜欢
    • 2017-11-23
    • 1970-01-01
    • 1970-01-01
    • 2017-08-15
    • 1970-01-01
    • 2019-04-17
    • 2019-08-10
    • 2011-07-25
    相关资源
    最近更新 更多