Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pinned-rows.rst #955

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/pages/pinned-rows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ Example::
{"first_name": "Trine", "last_name": None}
]

To generate dynamic rows based on calculations of all rows that may be similar to a footer we can access to data from the table. As shown in the example below we collect all the data and create a polars dataframe where we can aggregate the data as needed.

Example::

class Table(tables.Table):
item = tables.Column()
quantity = tables.Column()
price = tables.Column()

def get_bottom_pinned_data(self):
df = polars.DataFrame(list(self.data))
# get totals for each column
result = df.sum()
# return the dataframe as a list of dicts
return result.to_dicts()

.. note:: If you need very different rendering for the bottom pinned rows, chances are
you actually want to use column footers: :ref:`column-footers`

Expand Down