Monday, 7 January 2019

angular ui grid gridApi.infiniteScroll.on.needLoadMoreData not works when changed in data

I am using angular ui-grid 3.2.5

Following is 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;
    }
};

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

when we are performing scrolling gridApi.infiniteScroll.on.needLoadMoreData($scope, $scope.getDataDown); working well but we are pushing new data when data change in grid $scope.$watch( 'data', updateGrid); then on end of scrolling gridApi.infiniteScroll.on.needLoadMoreData not calles getDataDown method & scroll stops although there is more data.

What could be issue ?



from angular ui grid gridApi.infiniteScroll.on.needLoadMoreData not works when changed in data

No comments:

Post a Comment