2017-04-15 48 views
0

我已經使用jquery datatable在表中顯示我的數據。所有工作正常我只是有一個問題。我的桌子上有顯示有效的列&非活動客戶。我想對有效的&非活動客戶進行計數,因爲我有以下腳本。在這裏,我試圖計算每行中具有活動值的行,但它計算了總行數。計數在jQuery數據表中具有特定值的行

<script type="text/javascript"> 
     $(document).ready(function() { 
      $('#example').dataTable({ 
       "bLengthChange": true, 
       "paging": true, 
       "sPaginationType": "full_numbers" ,     //For Different Paging Style 
       "scrollY": 400,          // For Scrolling 
       "jQueryUI": false,          //Enabling JQuery UI(User InterFace) 
       "lengthMenu": [[30, 50, 100, -1], [30, 25, 50, "All"]], 
       drawCallback: function (settings) { 
        var api = this.api(); 
        // get the number of rows, but remove the page:current if you want number of rows in entire dataset 
        var count = api.rows({ 
         api: $('#example tbody tr td[value="active"]') 
        }).data().length; 
        // this takes the count and appends it in a span tag to the dataTables pageinate div element 
        $('<span id="active_rows"></span>').html(count + ' rows').appendTo($('.dataTables_info')); 
       } 
      }); 
     }); 
    </script> 

回答

相關問題