2017-09-21 1 views
0

DataTables 1.19을 사용하여 페이지 매김을 지정하고 주로 2000 개가 넘는 레코드가있는 테이블을 최적화합니다. 실제로 페이지 당 500 개 이상을 보여주는 경우 여기,DataTables : 표시되는 항목이 작동하지 않습니다.

"10 2001의 항목 표시 1 것은"는 screenshot입니다 :

모든 것이 유일한 문제가 DataTables 말하는 것입니다, 잘 작동합니다.

코드 :

의 jQuery DataTables :

url = location.search; 

         var table = $('.data-table').dataTable({ 
          "bJQueryUI": true, 
          "sPaginationType": "full_numbers", 
          "sDom": '<""lri>t<"F"fp>', 
          "aaSorting": [], 
          "bServerSide": true, 
          "bProcessing": true, 
          "sAjaxSource": "/ledger/ajax"+url, 
          "fnServerParams": function(aoData) { 
          }, 
          "fnRowCallback": function(nRow, aData, iDisplayIndex) { 
//        console.log(nRow); 
//        console.log(aData); 
           $('td:eq(1)', nRow).css('text-align', 'right'); 
           $('td:eq(2)', nRow).css('text-align', 'right'); 
           $('td:eq(3)', nRow).css('text-align', 'right'); 
           $('td:eq(4)', nRow).css('text-align', 'right'); 
           $('td:eq(5)', nRow).css('text-align', 'right'); 
           $('td:eq(6)', nRow).css('text-align', 'right'); 

          }, 
          "oLanguage": { 
           "sUrl": "/js/language/" + js_lang + ".txt" 
          }, 
          "bStateSave": true 
         }); 

Here은 AJAX 응답의 간단한 미리보기입니다.

나는 모든 의견을 고맙게 여기고 있습니다. 감사!

+1

:

는 내가 AJAX 응답의 구조를 해결하기 위해이 작업을 수행했다. 따라서 서버 측에서 iTotalRecords 및 iTotalDisplayRecords에 대해 잘못된 숫자를 반환 할 수 있습니다. –

답변

0

페이지 길이 설정을 시도 했습니까?

"iDisplayLength": 50 

나는 기본 값이 10 있어야하는데 알고 있지만 한번 시도해 ...

그리고 난 당신이 ... PHP는의 아마 발발했습니다 대답을 서버 측 처리를 사용하는 것을 볼 수 파일의 형식에 오류가 있습니다. 가능한 경우 답변을 붙여 넣습니다 (모든 행이 필요하지 않고 시작과 끝만 필요).

0

방금 ​​고쳤습니다. 문제는 데이터로 AJAX 쿼리를 작성하기 위해 데이터베이스에서 직접 쿼리 대신 데이터 컬렉션을 만들었습니다 (저는 Datatable :: query ($ data)를 사용하지 않았습니다). 그래서 AJAX 응답 구문은 잘못된. 사실 : 당신은 bServerSide 활성화

public function getAjax() 
    { 
     $inputs = Input::only(['period','date_start', 'date_end', 'grupoContable']); 
     $inputs = array_filter($inputs); 

     $results = $this->calculateAsientos($inputs); 

     $collection = new \Illuminate\Database\Eloquent\Collection; 

     foreach($results as $result) { 
      $collection->add($result); 
     } 


     return Datatable::collection($collection) 
      ->showColumns( 'fecha', 'comentarios', 'line_cargo', 'line_abono', 'nombreCuentaContable', 'cuentaContable') 
      ->searchColumns( 'fecha', 'comentarios', 'line_cargo', 'line_abono', 'nombreCuentaContable', 'cuentaContable') 
      ->orderColumns( 'fecha', 'cuentaContable', 'nombreCuentaContable', 'comentarios', 'line_cargo', 'line_abono') 
      ->make(); 
    } 
관련 문제