Jon Kennedy
Jon Kennedy

Reputation: 572

Angular ui grid pagination. How display item count based on filtered items?

This is what the pagination currently gives (The total # of items returned by the api):

enter image description here

The Problem is I am filtering the data using the columndefs.

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

The result of this filter is a limited # of items. In the current case '3'.
I believe the item count is linked to 'grid.options.totalitems'.
The count is correct when I change data or select a filter.
It is wrong when the page first loads.

I am using angular ui grid and django to set up my project. I am trying to fix this within my controller that handles the grid setup.
Thanks for any help you can offer.

Upvotes: 1

Views: 1145

Answers (2)

Jon Kennedy
Jon Kennedy

Reputation: 572

The fix that worked for me: On the $http.get that populates the grid info I had to add:

$scope.gridApi.grid.queueGridRefresh();

In the controller, here's the code with no errors.

$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


    },

And I had to put the http.get inside of the 'onRegisterApi'.

Upvotes: 0

Ali Adravi
Ali Adravi

Reputation: 22733

If you want to use the table then you need to write everything of your own.

Check this

Otherwise you can use the ng-grid which already have all the features.

Upvotes: 0

Related Questions