javascript - AngularJS ng-grid pagination issue - Buttons are not disabled -


i have following code,

demo: http://plnkr.co/edit/cijy45lgduvicxvwonlq?p=preview

html

<body ng-controller="myctrl">    <input type="text" ng-model="settings.filteroptions.filtertext" />    <div class="list" ng-grid="settings"></div> </body> 

js

var app = angular.module('myapp', ['nggrid']); app.controller('myctrl', function($scope, $filter) {   $scope.result = [];   $scope.all_data = [..............];   $scope.totalserveritems = 0;   $scope.selecteditems = [];   $scope.pagingoptions = {           currentpage : 1,           pagesize : 10           };   $scope.filteroptions = {           filtertext: '',           useexternalfilter : true           };   if(!$scope.settings){       $scope.settings = {           enablecolumnresize : true,           pagingoptions : $scope.pagingoptions,           filteroptions : $scope.filteroptions,           sortinfo: {fields: [], columns: [], directions: [] },           jqueryuitheme : true,           enablepaging : true,           useexternalsorting : true,           showfooter : true,           virtualizationthreshold: 100       };   }    $scope.settings.data = 'result';   $scope.settings.totalserveritems = 'totalserveritems';   $scope.settings.selecteditems = $scope.selecteditems;    $scope.$watch('pagingoptions', function (new_value, old_value) {       if($scope.filteroptions.filtertext != ''){         return false;       }       var pageddata = $scope.all_data.slice((new_value.currentpage - 1) * new_value.pagesize , new_value.currentpage * new_value.pagesize);       $scope.result = pageddata;       $scope.totalserveritems = $scope.all_data.length;       if (!$scope.$$phase) {           $scope.$apply();       }   }, true);    $scope.$watch('filteroptions', function (new_value, old_value) {       if(new_value){           $scope.result = $filter('filter')($scope.all_data, $scope.filteroptions.filtertext);           if (!$scope.$$phase) {               $scope.$apply();           }       }   }, true); }); 

problem

when filter random keywords, grid gets empty pagination buttons not disabled, can still click remaining number of pages. can explain me problem?


update fixed making small change in filteroptions watch. looks like,

demo http://plnkr.co/edit/ullg6autbprmxecr7exc?p=preview

js

$scope.$watch('filteroptions', function (new_value, old_value) {       if(new_value){           $scope.result = $filter('filter')($scope.all_data, $scope.filteroptions.filtertext);           $scope.totalserveritems = $scope.result.length; //this helped out fix issue           if (!$scope.$$phase) {               $scope.$apply();           }       }   }, true); 

thanks in advance.

sorry, i'm late.

i got working adding modified footer template script:

    var ft= "<div ng-show=\"showfooter\" class=\"ngfooterpanel\" ng-class=\"{'ui-widget-content': jqueryuitheme,       ....      "            <button class=\"ngpagerbutton\" ng-click=\"pageforward()\" ng-disabled=\"cantpageforward()|| result.length < pagingoptions.pagesize\" title=\"{{i18n.ngpagernexttitle}}\"><div class=\"ngpagerlasttriangle ngpagernexttriangle\"></div></button>" +     "            <button class=\"ngpagerbutton\" ng-click=\"pagetolast()\" ng-disabled=\"cantpagetolast()|| result.length < pagingoptions.pagesize\" title=\"{{i18n.ngpagerlasttitle}}\"><div class=\"ngpagerlasttriangle\"><div class=\"ngpagerlastbar\"></div></div></button>" +      .... 

and assigning grid with:

  $scope.settings = {     ...       footertemplate:ft   }; 

i'm leave weekend can't test throughly, hope helps anyhow.

here's plunker play around it.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -