daniel-nagy / md-data-table

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

Pagination using server side data loading #594

Open ghost opened 7 years ago

ghost commented 7 years ago

Please can you show me the steps to implement pagination using back end calls by sending limit and offset values and loading the results back to the table. I have done the client side pagination and sincey data base consist of large amount of data i need to swith to server side data loading when changing pages Thanks in advance

ghost commented 7 years ago
var bookmark;
var self = this;

self.query = {
      'limit': 10,
      'offset': '',
      'page': 1
    };

$scope.$watch(angular.bind(this, function () {
      return this.query;
    }), function (newValue, oldValue) {
      if(!oldValue) {
        bookmark = self.query.page;
      }

      if(!newValue) {
        self.query.page = bookmark;
      }

      getData();
    }, true);

function getData() {
      self.promise = *** request to server with self.query params (need return promise)***
    }

<table class="mtable" md-table md-progress="someCtrl.promise">
</table>

<md-table-pagination md-limit="someCtrl.query.top" md-page="someCtrl.query.page"></md-table-pagination>
sachindu commented 2 years ago

Hello there please let me know if your code working fine .. i would like to do same server side pagination as data is huge.. Please provide code where i need to change .. thanks in advance