在我的应用程序中,我具有无限滚动的ui网格。我将库包含在我的App中并声明。
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'
]);
在我的控制器上:
$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 );
}
};
在我的代码$ scope.gridApi上未定义,为什么?为什么我的网格无法在onRegisterApi上启动?在我的HTML代码中,网格包括
<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>
非常感谢您的帮助。