I am using angular-ui-grid
3.2.5
Scrolling with gridApi.infiniteScroll.on.needLoadMoreData($scope, $scope.getDataDown)
is working well, but when we are pushing new data when data changes in grid via $scope.$watch('data', updateGrid)
, then on the end of scrolling gridApi.infiniteScroll.on.needLoadMoreData
doesn't call getDataDown
method and scrolling stops although there is more data.
Here are the gridOptions
:
$scope.gridOptions = {
infiniteScrollRowsFromEnd: 40,
infiniteScrollUp: true,
infiniteScrollDown: true,
enableColumnMenus: false, // Remove hide columns options
columnDefs: $scope.myDefs,
data: 'data',
onRegisterApi: function (gridApi) {
gridApi.infiniteScroll.on.needLoadMoreData($scope, $scope.getDataDown);
gridApi.infiniteScroll.on.needLoadMoreDataTop($scope, $scope.getDataUp);
$scope.gridApi = gridApi;
}
};
Here's the updateGrid()
implementation
function updateGrid(filteredData) {
$scope.response = filteredData;
$scope.firstPage = 1;
$scope.lastPage = 1;
$scope.totalPages = Math.ceil($scope.response.length / $scope.pageSize);
$scope.gridApi.infiniteScroll.setScrollDirections(false, false);
$scope.data = [];
$scope.data = $scope.response.slice(0, $scope.pageSize);
$timeout(function () {
$scope.gridApi.infiniteScroll.resetScroll($scope.firstPage > 0, $scope.lastPage < $scope.totalPages);
});
};
What could be the issue ?
$scope.getDataDown
and$scope.getDataUp
– Hefner