Leeuwtje
Leeuwtje

Reputation: 2281

how to fix ngtable pagination?

I have developed a ngtable with a filter. The pagination on the table does not work anymore though? When I select the show 10 rows on the bottom of the table it still shows 14 rows? How can i fix the pagination/indexing?

This is my table definition:

<table ng-table="tableParams" class="table">
     <tr ng-repeat="account in $parent.filtered =(data  | filter:search.accountName | filter:search.id)">
          <td data-title="'id'">
                {{account.account.accountId.id}}
          </td>
          <td data-title="'name'">
                {{account.account.accountName}}
          </td>
     </tr>
</table>

plunkr:http://plnkr.co/edit/Rqt6px?p=preview

Upvotes: 0

Views: 578

Answers (1)

waitingduck
waitingduck

Reputation: 155

You need to figure pagination function by yourself. You may see ng-table's example in here.

var Api = $resource("/data");
this.tableParams = new NgTableParams({}, {
  getData: function(params) {
    // ajax request to api
    return Api.get(params.url()).$promise.then(function(data) {
      params.total(data.inlineCount); // recal. page nav controls
      return data.results;
    });
  }
});

It first load all the data into Api. The params.url() contains current page and page count. It then use these two variable to return part of dataset. So you may need to figure out how to return this part of data.

Upvotes: 0

Related Questions