daniel-nagy / md-data-table

Material Design Data Table for Angular Material
MIT License
1.9k stars 519 forks source link

Is there a way to reset pagination if there is a change in md-total (i.e change in the total number of rows) #176

Open sbharadwaj92 opened 9 years ago

sbharadwaj92 commented 9 years ago

I want to reset the pagination after there is a change with the total number of rows

yhbrandon commented 8 years ago

Is this after filtering? Or an actual change in the data?

Webenius commented 8 years ago

How to do it after filtering?

tucq88 commented 8 years ago

I think you could watch on the data you want to check and then change the page back to 1.

Like this. Whenever I do filtering, I'll reset the page to 1.

$scope.$watch('query.filter', function(val) {
        $scope.query.page = 1;
    });
daniel-nagy commented 8 years ago

You can change the page within your controller and it should update the table.

I just released a big update with lots of changes and new features, check it out!

On Dec 27, 2015, at 10:59 PM, Tu Chu Quang notifications@github.com wrote:

I think you could watch on the data and then change the page back to 1.

Like this. Whenever I do filtering, I'll reset the page to 1.

$scope.$watch('query.filter', function(val) { $scope.query.page = 1; }); — Reply to this email directly or view it on GitHub https://github.com/daniel-nagy/md-data-table/issues/176#issuecomment-167477284.

tucq88 commented 8 years ago

WOW. What an update. Thanks a lot @daniel-nagy

antoinebrault commented 8 years ago

Made a pull request (https://github.com/daniel-nagy/md-data-table/pull/285) to reset the page to 1 if current page index > total

patfrat commented 8 years ago

I have had the same problem that i resolved by using a filtered parameter and setting page to 1 whenever a filter changed

<md-table-pagination md-total="{{filtered.length}}" ...></md-table-pagination>
...
<tr md-row ng-repeat="item in filtered = (items | filter: myFilters)">
...
</tr>