角度ui网格分页。如何根据过滤的项目显示项目数?

时间:2015-09-09 16:41:48

标签: python angularjs django pagination angular-ui-grid

这是分页当前给出的内容(api返回的项目总数):

enter image description here

问题是我使用columndef过滤数据。

field: 'claimed', displayName: 'Claimed', width: '8%', visible: true,
filter: {
     term: false,
     type: uiGridConstants.filter.SELECT,
     selectOptions: [{value: true, label: true}, {value: false, label: false}]

此过滤器的结果是有限的项目数。在目前的情况下' 3'。
 我认为项目计数与' grid.options.totalitems'相关联。
更改数据或选择过滤器时,计数是正确的。
页面首次加载时出错。

我使用角度ui grid和django来设置我的项目。我正在尝试在处理网格设置的控制器中修复此问题 感谢您提供的任何帮助。

2 个答案:

答案 0 :(得分:0)

如果您想使用该表,则需要编写自己的所有内容。

Check this

否则,您可以使用已具备所有功能的ng-grid

答案 1 :(得分:0)

对我有用的修复: 在$ http.get上填充我必须添加的网格信息:

$scope.gridApi.grid.queueGridRefresh();

在控制器中,这是没有错误的代码。

$scope.gridOptions = {
    onRegisterApi: function (gridApi) {
        $scope.gridApi = gridApi;
        gridApi.rowEdit.on.saveRow($scope, $scope.saveRow);

        $http.get('/api/this/?format=json')
            .success(function (data) {
                $scope.gridOptions.data = data;
                $scope.gridApi.grid.queueGridRefresh();
        });  //Ends http.get


    },

我必须将http.get放在'onRegisterApi'中。

相关问题