简体   繁体   English

如何在ui bootstrap分页中禁用下一个按钮?

[英]How to disable next button in ui bootstrap pagination?

I am trying to create pagination in my page and using pagination control. 我试图在我的页面中创建分页并使用分页控件。 Everything works fine, but only doubt is how to manually disable next button here 一切正常,但唯一的疑问是如何在这里手动禁用下一个按钮

<pagination   
    total-items="totalItems" 
    items-per-page= "itemsPerPage"
    ng-model="currentPage" 
    class="pagination-sm"  
    page="currentPage"
    max-size= "maxSize"
    ng-change="pageChanged(currentPage)">
</pagination> 

In my controller- 在我的控制器中 -

$scope.currentPage=1;
$scope.itemsPerPage = 5;
$scope.maxSize = 2;
$scope.numberofrows =5;

 $scope.fetchResult =function(startingId){
                  if(startingId ==undefined){
                      $scope.StartingId = ''; 
                  }
                  else{
                      $scope.StartingId= startingId ; 
                  }
                  Api.customerReq.queryProductbyperiod({ productId : $scope.customerProduct , productperiod :$scope.customerPeriod,startingid: $scope.StartingId,numberofrows:$scope.numberofrows}).$promise.then(function(result) {
                        if(result){
                            if(result&&result.length==0){
                                // error alert 
                                }
                            $scope.customerResult = result;
                            if($scope.currentPage==1){
                             $scope.NextStartingId = result[5].id;
                             // on landing page storing last stringId for the next request to cassandra since row num requested as 6.
                            }
                            else{
                            $scope.NextStartingId = result[4].id;  // rest of the page, row num requested as 5.
                            }

                    $scope.previousStartingId=$scope.NextStartingId; 
                            if($scope.currentPage== 1){ 
                                $scope.totalItems= result.length;
                            }
$scope . pageChanged = function (page) {
    if (page > $scope . count)
    {
        $scope . count ++;
        //  temp = page;
        $scope . nextPage();
    } else
    {
        $scope . count = page;
        $scope . prevPage();
    }
};

              $scope.prevPage = function() {
                  if($scope.currentPage ==1){
                         $scope.previousStartingId = '';
                        }
                  $scope.fetchResult($scope.previousStartingId);
                  if($scope.currentpage>1)
                       $scope.totalItems -=5;

              };
             $scope.nextPage = function() {
                 if($scope.currentPage!=1){
                     $scope.numberofrows =5;

                 }                               
                 $scope.fetchResult($scope.NextStartingId);

                  $scope.totalItems +=5;     
                  };

Here calling next and previous page on each pagechange. 这里在每个页面上调用下一页和上一页。 What I am missing or how to manually disable nextlink? 我缺少什么或如何手动禁用nextlink? or how datepicker will work in this situation? 或者datepicker如何在这种情况下工作?

Yes I do api request each time I hit next or prev button, as cassandra has very limited support to pagination. 是的,每当我点击下一个或上一个按钮时我都会做api请求,因为cassandra对分页的支持非常有限。 So each time am querying with stored stringId to filter the result as they are storing in Cassandra table as ordered list. 所以每次查询存储的stringId来过滤结果,因为它们作为有序列表存储在Cassandra表中。 So it is more like server side pagination am doing here. 所以它更像是服务器端分页在这里做的。

UI boortstrap will automatically disable next link if there are no pages to show. 如果没有要显示的页面,UI boortstrap将自动禁用下一个链接。 You don't need to use ng-change for disabling pagination items. 您无需使用ng-change来禁用分页项。 I't supposed for other handlers if you need them, for example confirmation or ajax request. 如果你需要它们,我不应该为其他处理程序,例如确认或ajax请求。 You can check by following formula: 您可以通过以下公式进行检查:

totalItems / temsPerPage - maxSize

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM