Skip to content

Commit

Permalink
Documentation for pinned rows
Browse files Browse the repository at this point in the history
  • Loading branch information
djk2 committed Feb 26, 2017
1 parent 962660d commit 5eb71dd
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/pages/customizing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ Customizing the table
query-string-fields
localization-control
generic-mixins
pinned-rows
67 changes: 67 additions & 0 deletions docs/pages/pinned-rows.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
.. _pinned_rows:

Pinned rows
===========

By using Pinned Rows, you can pin particular rows to the top or bottom of your table.
To add pinned rows to your table, you must overridden `get_top_pinned_data` and/or `get_bottom_pinned_data`
methods in your `.Table` class.

* `get_top_pinned_data(self)` - Display the pinned rows on top.
* `get_bottom_pinned_data(self)` - Display the pinned rows on bottom.

By default both methods return `None` value and pinned rows aren't visible.
Return data for pinned rows should be iterable type like: queryset, list of dicts, list of objects.


Example::

class Table(tables.Table):

def get_top_pinned_data(self):
return [
# First top pinned row
{
'column_a' : 'value for A column',
'column_b' : 'value for B column'
},
# Second top pinned row
{
'column_a' : 'extra value for A column'
'column_b' : None
}
]

def get_top_pinned_data(self):
return [{
'column_c' : 'value for C column',
'column_d' : 'value for D column'
}]


.. note:: Sorting and pagination for pined rows not working.

Value for cell in pinned row will be shown only when **key** in object has the same name as column.
You can decide which columns for pinned rows will visible or not.
If you want show value for only one column, use only one column name as key.
Non existing keys won't be shown in pinned rows.


.. warning:: Pinned rows not exist in ``table.rows``. If table has some pinned rows and
one normal row then length of ``table.rows`` is 1.


.. _pinned_row_attributes:

Pinned rows attributes
========================
If you wont override HTML attributes for pinned rows you can use: ``pinned_row_attrs``.
Pined row attributes can be specified using a `dict` defining the HTML attributes for
the ``<tr>`` element on each row. See more: :ref:`row-attributes`.

.. note:: By default pinned rows have ``pinned-row`` css class.

.. sourcecode:: django

<tr class="odd pinned-row" ...> [...] </tr>
<tr class="even pinned-row" ...> [...] </tr>

0 comments on commit 5eb71dd

Please sign in to comment.