Utilities for interfacing with FixedDataTable.js
Project description
Python utilities for building and rendering FixedDataTable components that can easily be sorted, filtered, and exported to Excel.
Installation
Install the python package:
pip install fixeddatatable
Install the javascript libary with bower:
bower install fixed-data-table-py
Usage Overview
Build table rows as a list of lists or a list of dicts
Build Column objects with arguments that match the column props in the fixed-data-table column API
Create a Table object and pass the rows and columns as arguments
In your template, create the FixedDataTablePy React component and pass in the Table.json as the options property.
Other Functionality
number formatting: give the column a num_format property with a numeral.js format string
filtering: pass the Table constructor the data key to filter by and a placeholder to enable filtering
exporting: pass the Table constructor the filename and the table header will include a button to export the table data to a .xlsx file
Example
See the sample_project for a full example of a Flask app.
In your view:
from fixeddatatable import Table, Column rows = [ {'col1': 'a1', 'col2': 'b1', 'col3': '0.99'}, {'col1': 'a2', 'col2': 'b2', 'col3': '0.12313'}, {'col1': 'a3', 'col2': 'b3', 'col3': '1.04'}, ] cols = [ Column(label='Col 1', key='col1', width=100), Column(label='Col 2', key='col2', width=100), Column(label='Col 3', key='col3', width=100, num_format='0.0%'), ] tbl = Table(row_height=50, width=300, height=500, columns=cols, rows=rows, filter={'key': 'col2', 'placeholder': 'Filter by Col 2'}, export_filename='SampleProject.xlsx')
In your template:
<div id="datatable"></div> <script type="text/javascript"> var tableData = tbl.json|safe; React.render( React.createElement(FixedDataTablePy, {options: tableData}), document.getElementById('yourid') ); </script>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file fixeddatatable-0.0.2.tar.gz
.
File metadata
- Download URL: fixeddatatable-0.0.2.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1c68e74ccf311baa03f9b0471b3e6c31960abd95b46cec85ca9a1986231d7e8 |
|
MD5 | 2f10909b92087d5294b483bae9024731 |
|
BLAKE2b-256 | 3c57df683a54638ed5c43a5668cb8a9c115e37def23155dd5f75cc3a8c63b658 |