2017-11-01 4 views
0

私はdatatablesを使用しているsymfony 3でアプリケーションを開発しています。データテーブルの合計行数を変更する方法

データベースのすべての行を取得しないようにするには、imはdoctrineのpaginatorを使用します。だから私はdatatableが最初に100要素を取得したい、次に私は次のボタンをクリックすると、次の100要素を充電します。

私の問題は、最初の100要素でdatatableを設定すると、次のボタンをクリックすることです。 (100要素を表示しているので、他の要素はありません)。私は100以上の要素を持っていると伝えたい。どうすればいいのですか?

マイテーブル:

<table class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%" 
        id="table_city"> 
       <thead> 
       <tr> 
        <th>Code</th> 
        <th>Name</th> 
        <th>Region</th> 
        <th>Country</th> 
        <th class="no-sort">Actions</th> 
       </tr> 
       </thead> 
       <tbody> 
       {% for core_city in core_cities %} 
        <tr> 
         <td>{{ core_city.code }}</td> 
         <td>{{ core_city }}</td> 
         <td>{{ core_city.CoreRegion }}</td> 
         <td>{{ core_city.CoreRegion.coreCountry }}</td> 
         <td class="datatable_td_buttons"> 
          <a class="m-portlet__nav-link btn m-btn m-btn--icon m-btn--icon-only m-btn--pill" 
           title="Show" href="{{ path('core_city_show', { 'id': core_city.id }) }}"> 
           <i class="la la-search"></i> 
          </a> 
          <a href="{{ path('core_city_edit', { 'id': core_city.id }) }}" 
           class="m-portlet__nav-link btn m-btn--icon m-btn--icon-only m-btn--pill" title="Edit"> 
           <i class="la la-edit"></i> 
          </a> 
          <a href="{{ path('core_zip_code_import_by_city', { 'id': core_city.id }) }}" 
           class="m-portlet__nav-link btn m-btn--icon m-btn--icon-only m-btn--pill" 
           title="Import Zip Code"> 
           <i class="la la-upload"></i> 
          </a> 
         </td> 
        </tr> 
       {% endfor %} 
       </tbody> 
      </table> 
+1

あなたがサーバーサイド処理を使用する必要があり、それはここで、このためにsymfonyのバンドルがあるようです - > ** HTTPS:/を/github.com/webinarium/DataTablesBundle** – davidkonrad

+0

ありがとうございます:) – Ld91

答えて

0

私は解決策が見つかりました:

$('#example').dataTable({ 
    "infoCallback": function(settings, start, end, max, total, pre) { 
    return start +" to "+ end; 
    } 
}); 
関連する問題