* Added pagination
[django-tables2.git] / django_tables / templates / django_tables / table.html
1 {% spaceless %}
2 {% load django_tables %}
3 {% if table.page %}
4 <div class="table-container">
5 {% endif %}
6 <table{% if table.attrs %} {{ table.attrs.as_html }}{% endif %}>
7     <thead>
8         <tr class="{% cycle "odd" "even" %}">
9         {% for column in table.columns %}
10         {% if column.sortable %}
11             {% with column.order_by as ob %}
12             <th class="{% spaceless %}{% if column.sortable %}sortable {% endif %}{% if ob %}{% if ob.is_descending %}desc{% else %}asc{% endif %}{% endif %}{% endspaceless %}"><a href="{% if ob %}{% set_url_param sort=ob.opposite %}{% else %}{% set_url_param sort=column.name %}{% endif %}">{{ column.header }}</a></th>
13             {% endwith %}
14         {% else %}
15             <th>{{ column.header }}</th>
16         {% endif %}
17         {% endfor %}
18         </tr>
19     </thead>
20     <tbody>
21         {% for row in table.page.object_list|default:table.rows %} {# support pagination #}
22         <tr class="{% cycle "odd" "even" %}">
23             {% for cell in row %}
24                 <td>{{ cell }}</td>
25             {% endfor %}
26         </tr>
27         {% endfor %}
28     </tbody>
29 </table>
30 {% if table.page %}
31 <ul class="pagination">
32     {% if table.page.has_previous %}
33     <li class="previous"><a href="{% set_url_param page=table.page.previous_page_number %}">Previous</a>
34     {% endif %}
35     <li class="current">Page {{ table.page.number }} of {{ table.paginator.num_pages }}</li>
36     {% if table.page.has_next %}
37     <li class="next"><a href="{% set_url_param page=table.page.next_page_number %}">Next</a>
38     {% endif %}
39     </span>
40 </div>
41 </div>
42 {% endif %}
43 {% endspaceless %}