UI Grid showing only last record many times on infinite scroll

347 views Asked by At

Before Scrolling

After Scrolling

In Grid on first time load I am getting data properly. After scrolling down it is getting problem. It displays last record from the first load's last record in every row.

Below is my code for infinite scroll function.

$scope.getDataDown = function() {
  var promise = $q.defer();
  $scope.lastPage++;
  if ($scope.data.length < $scope.total) {
    $http(getRequest()).success(function(data) {
      promise.resolve();
      var jb = JSON.stringify(data.content);
      $scope.gridApi.infiniteScroll.saveScrollPercentage();
      $scope.data = $scope.data.concat(data.content);
      $scope.total = data.total ? data.total : data.length;
      $scope.length = $scope.data.length;
      $scope.gridApi.infiniteScroll.dataLoaded(false,
          $scope.lastPage < ($scope.total / $scope.pageSize));
    }).error(function(error) {
          $scope.gridApi.infiniteScroll.dataLoaded();
        });
  }
  return promise.promise;
};
1

There are 1 answers

0
Dip Parmar On BEST ANSWER

I figured it out. Funciton is right but I used below function in my code it was conflicting with this function

$scope.gridOptions.rowIdentity = function(row) { return row.id; };