如何更改ng-grid和分页问题中的Total Item Value

时间:2015-07-29 12:30:36

标签: javascript angularjs ng-grid

我正在使用ng-grid。它的工作正常 但" Total Item"的价值仅显示当前页面项目长度 我需要显示一个总数组项长度,而不仅仅是当前页面项长度。

我的数组大小为55
我的页面大小是:15
然后显示总项目为15.
但我需要:Total Item是55。

另一个问题是::

ng-grid分页无法点击" last"按钮
和" next"按钮移动到一个额外的页面..

                $scope.filterOptions = {
                        filterText: "",
                        useExternalFilter: true
                    };
                    $scope.pagingOptions = {
                        pageSizes: [5,15, 25, 50],
                        pageSize: 15,
                       currentPage: 1
                    };      
                         $scope.setPagingData = function(data, page, pageSize){    
                        var pagedData = data.slice((page - 1) * pageSize, page * pageSize);
                        $scope.myData = pagedData;
                        if (!$scope.$$phase) {
                            $scope.$apply();
                        }
                    };        
                     $scope.getPagedDataAsync = function (pageSize, page, searchText) {    
                         setTimeout(function () {    
                            var data;    
                            if (searchText) {    
                                var ft = searchText.toLowerCase();    
                                $scope.setPagingData($scope.allalert,page,pageSize);
                            } else {
                                alert=[[],[]];
                                service.getallalert(accountid)
                                .success(function(data,status,headers,config) {
                                        var len=data.all_alert.length;

                                        var lenmessage=0;
                                        for(var i=0;i<len;i++){
                                            $scope.devicenameinalert=data.all_alert[i].devicename;
                                            lenmessage=data.all_alert[i].message_list.length;

                                            if(lenmessage!=0){
                                                for(var j=0;j<lenmessage;j++){

                                                    alert.push(data.all_alert[i].message_list[j]);
                                                }
                                            }
                                        }
                                        $scope.allalert=alert;
                                        $scope.allalert.splice(0,2);

                                        if($scope.allalert.length==0){
                                            toaster.pop("error", "Not Found", "Record Not Found.");
                                        }else{
                                            $scope.setPagingData($scope.allalert,page,pageSize);
                                        }
                                    })
                                    .error(function(data,status,headers,config)
                                            {
                                            });     
                            }
                        }, 100);
                    };



                       $scope.gridOptions = {        

                        data: 'myData', selectedItems: [] ,
                        enablePaging: true,
                        pagingOptions: $scope.pagingOptions,
                        showFooter: true, 
                        filterOptions: $scope.filterOptions,
                        plugins: [new ngGridFlexibleHeightPlugin()]
                    };
                    $scope.selectedCityInfo = [];
                    $scope.gridOptions.enableRowSelection = true;
                    $scope.gridOptions.showSelectionCheckbox = true;
                    $scope.gridOptions.multiSelect = true;
                    $scope.gridOptions.showSelectionCheckbox=true;
                    $scope.gridOptions.showColumnMenu = false;
                    $scope.gridOptions.columnDefs = 'gridColumnDefs';

                    $scope.gridColumnDefs = [ {field:'devicename',cellTemplate: '<div class="margincenter"><center>{{row.entity.devicename}}</center></div>',headerCellTemplate: '<div class="textCenter">Device Name</div>'},
                                              {field:'alerttime',displayName: 'Date/Time'},
                                              {field:'message',displayName: 'Message'}
                                              ];

0 个答案:

没有答案