2017-11-01 1 views
0

Ich entwickle eine Anwendung mit Symfony 3 in denen ich Daten Tabellen verwende.Wie ändere ich die Anzahl der Gesamtzeilen in Datentabelle

um zu vermeiden, alle Zeilen der Datenbank zu bekommen, ich benutze Doktrin Paginator. also möchte ich, dass die Datentabelle zuerst 100 Elemente erhält, und wenn ich dann in die nächste Schaltfläche klicke, werden die nächsten 100 Elemente geladen.

Mein Problem ist, dass wenn ich Datatable mit ersten 100 Elementen setze, ich c'ant auf nächste Schaltfläche klicken kann. (Weil es die 100 Elemente zeigt, also gibt es keine anderen Elemente dafür). Ich möchte sagen, dass ich mehr als 100 Elemente habe. also wie kann ich es tun.

Meine Tabelle:

<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

Sie serverseitige Verarbeitung verwenden müssen, scheint es, dass es ein symfony-Bundle für das hier ist -> ** https://github.com/webinarium/DataTablesBundle** – davidkonrad

+0

Okay danke :) – Ld91

Antwort

0

I-Lösung gefunden:

$('#example').dataTable({ 
    "infoCallback": function(settings, start, end, max, total, pre) { 
    return start +" to "+ end; 
    } 
}); 
Verwandte Themen