Search code examples
angularjsangular-ui-gridui-gridangularjs-1.6

Why Angular UI-Grid is not working with angular updated version 1.6.5?


I am facing a problem which is, my Angular ui-grid is failed to load data in it's grid when I am using updated version of angular JS. It's working fine with angular lower version of 1.5.0 however, not working with 1.6.5.

Additionally, it's not showing any error regarding the grid too. According to the Ui-grid documentation I can see that they have only used angular 1.5.0, but what about the latest version like 1.6.+

I don't prefer using the older version of angualr js. And I am using the latest version of ui-grid(4.0.11, latest) so do the Angular too.

Could you suggest anything regarding this or, any alternative grid having same facilities?

Link using 1.6.5

Link using 1.5.0


Solution

  • In your second example, use this for your $http method:

      $http.get(url)
        .then(function(resp) {
          $scope.gridOptions.totalItems = 100;
          var firstRow = (paginationOptions.pageNumber - 1) * paginationOptions.pageSize;
          $scope.gridOptions.data = resp.data.slice(firstRow, firstRow + paginationOptions.pageSize);
        });
    

    The minimal change is just to change your 1.6.5 to this. The response object contains headers, so you need the data property from it.

    $scope.gridOptions.data = response.data.slice(firstRow, firstRow + paginationOptions.pageSize);