1

In my application i have the ui-grid with infinite scroll. I include the libraries on my App and declare it.

var TestApp = angular.module('TestApp', [
'angucomplete-alt', 
'ngRoute', 
'infinite-scroll', 
'moment-picker',
'errorInterceptor',
'ui.select',
'ngSanitize',
'backToTop',
'stompNotifications',
'HeaderApp',
'ui.grid',
'ui.grid.autoResize',
'ui.grid.grouping',
'moment-picker',
'ui.grid.exporter',
'ui.grid.edit',
'ui.grid.cellNav',
'ui.grid.infiniteScroll',
'ngDialog'
]);

On my controller:

    $scope.grid = {
            enableColumnMenus: false,
            enableSorting: true,
            enableFiltering: true, 
            enableHiding: true,
            enableInfiniteScroll: true,
            infiniteScrollUp: true,
            infiniteScrollDown: true,
            infiniteScrollRowsFromEnd: 40,
            columnDefs: [
                { field: 'code',            cellTooltip: true, width: "25%", displayName: 'Code', filter: {disableCancelFilterButton: true}},
                { field: 'description',     cellTooltip: true, width: "60%", displayName: 'Description', filter: {disableCancelFilterButton: true}},
                { field: 'id', displayName: 'Actions', cellTemplate: '../resources/default/ui/views/azioni.html', width: "15%"},
            ],
            enableGridMenu: true,
            onRegisterApi: function( gridApi ) {
                $scope.gridApi = gridApi;
                gridApi.infiniteScroll.on.needLoadMoreData($scope, $scope.getDataDown);
                gridApi.infiniteScroll.on.needLoadMoreDataTop($scope, $scope.getDataUp);
                $scope.gridApi.grid.registerColumnsProcessor( MainGridUtils.setGroupValues, 410 );

            }  
        };

On my code $scope.gridApi is undefined, Why? Why my grid not fire onRegisterApi? In my Html code the grid include

<div id="grid1" ui-grid="grid" class="grid" style="width: 100%; " ui-grid-ext ui-grid-auto-resize ui-grid-exporter ui-grid-infinite-scroll></div>

Thank's in advanced for help me.

Remko
  • 359
  • 2
  • 8
Bonci Marco
  • 301
  • 2
  • 5
  • 17
  • How did you declare your controller? – Remko Oct 08 '18 at 13:25
  • Why? I don't understand my controller is TestApp.controller('TestController', ['$rootScope', '$scope', '$location', '$routeParams', '$window', 'myservice', function ($rootScope, $scope, $location, $routeParams, $window, myservice) { – Bonci Marco Oct 15 '18 at 08:11
  • 1
    Seemed important :) I created a [plunkr](http://plnkr.co/edit/whzAaSy1ADL7fiOiHzgf?p=preview) using (most of) your code from above. It all seems to work fine there. Please check if there is something different in your code. – Remko Oct 15 '18 at 14:04

0 Answers0