【问题标题】:UI Grid showing only last record many times on infinite scrollUI Grid 在无限滚动时多次显示最后一条记录
【发布时间】:2017-05-06 12:11:30
【问题描述】:

Before Scrolling

After Scrolling

在第一次加载的网格中,我正在正确获取数据。 向下滚动后出现问题。 它显示每行中第一次加载的最后一条记录的最后一条记录。

下面是我的无限滚动功能代码。

$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;
};

【问题讨论】:

  • 还有一件事我在“data.content”中获得了正确的数据,但是在显示它时出现了问题

标签: angularjs angular-ui-grid infinite-scroll ui-grid


【解决方案1】:

我想通了。函数是对的,但我在代码中使用了下面的函数,它与这个函数冲突

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-31
    • 1970-01-01
    相关资源
    最近更新 更多