>>> $scope.getPagedDataAsync = function (pageSize, page, searchText) { >>> setTimeout(function () { >>> var data; >>> if ($scope.currentAccount) { >>> //var acctNameHash = $scope.currentAccount.acctNameHash; >>> //var showFinalized = $scope.showFinalized; >>> var largeLoad = $scope.currentAccount.invoices; >>> if (searchText) { >>> var ft = searchText.toLowerCase(); >>> //$http.get('/api/accounts/getAccountInvoices/' + acctNameHash + '/' + showFinalized) >>> // .success(function (largeLoad) >>> { >>> data = largeLoad.filter(function (item) { >>> return JSON.stringify(item).toLowerCase().indexOf(ft) != -1; >>> }); >>> // Always use first page after applying a filter >>> $scope.setPagingData(data, 1, pageSize); >>> }; >>> } else { >>> //$http.get('/api/accounts/getAccountInvoices/' + acctNameHash + '/' + showFinalized) >>> // .success(function (largeLoad) >>> { >>> $scope.setPagingData(largeLoad, page, pageSize); >>> } >>> //); >>> } >>> } >>> }, 100); >>> }; >>> >>> $scope.$watch('pagingOptions', function (newVal, oldVal) { >>> if (newVal !== oldVal && newVal.currentPage !== oldVal.currentPage) { >>> $scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage, $scope.filterOptions.filterText); >>> } >>> }, true); >>> >>> $scope.$watch('showFinalized', function (newVal, oldVal) { >>> if (newVal !== oldVal && $scope.currentAccount && !$scope.isNew) { >>> getAccountInvoices($scope.currentAccount.acctNameHash); >>> // This is part of the getAccountInvoices method >>> // $scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage, $scope.filterOptions.filterText); >>> } >>> }); >>> >>> $scope.$watch('filterOptions', function (newVal, oldVal) { >>> if (newVal !== oldVal) { >>> $scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage, $scope.filterOptions.filterText); >>> } >>> }, true); >>> >>> var linkCellTemplate = '<div class="ngCellText" ng-class="col.colIndex()">' + >>> ' <a href="{{row.getProperty(col.field)}}">{{row.getProperty(col.field)}}</a>' + >>> '</div>'; >>> var balanceCellTemplate = '<div ng-class="{\'field-validation-error\': row.getProperty(col.field) < 0}"><div class="ngCellText">{{row.getProperty(col.field)|currency}}</div></div>'; >>> $scope.gridOptions = { >>> data: 'gridData', >>> // showFooter: true, >>> enableColumnResize: true, >>> enableColumnReordering: true, >>> enableRowSelection: false, >>> enablePaging: true, >>> showFooter: true, >>> totalServerItems: 'totalServerItems', >>> pagingOptions: $scope.pagingOptions, >>> filterOptions: $scope.filterOptions, >>> //rowTemplate: '<div style="height: 100%" ng-class="{label label-danger pull-right: row.getProperty(\'hidden\') == true}"><div ng-style="{ \'cursor\': row.cursor }" ng-repeat="col in renderedColumns" ng-class="col.colIndex()" class="ngCell {{col.cellClass}}"><div class="ngVerticalBar" ng-style="{height: rowHeight}" ng-class="{ ngVerticalBarVisible: !$last }"> </div><div ng-cell></div></div></div>', >>> columnDefs: [ >>> { >>> field: 'invoiceNo', displayName: 'Invoice #', >>> width: 70, resizable: true, sortable: true, >>> enableCellEdit: false, >>> cellTemplate: linkCellTemplate >>> }, >>> { field: 'descrip', displayName: 'Description', width: 200, resizable: true, sortable: true }, >>> { field: 'created', displayName: 'Date Created', width: 150, resizable: true, sortable: true, cellFilter: "date: 'medium'" }, >>> >>> { >>> field: 'balance', displayName: 'Balance', resizable: true, sortable: true, >>> cellTemplate: balanceCellTemplate >>> }] >>> //,plugins: [new ngGridFlexibleHeightPlugin()] >>> }; >>> };>>>