0.0.3 • Published 5 years ago

dash_react_table v0.0.3

Weekly downloads
6
License
MIT
Repository
github
Last release
5 years ago

dash-react-table

Dash component for react-table

dash-react-table provides a lightweight table component built on top of react-table.

Note: This above link will take you to version 6 which is the one I used for this component (v6.8.6 to be exact)

Installation

dash-react-table is hosted on PyPI, and can be installed by running

pip install dash-react-table

Usage

import dash
import dash_html_components as html
import pandas as pd

from dash_react_table import DashReactTable

df = pd.read_csv(
    'https://raw.githubusercontent.com/plotly/datasets/master/solar.csv')


data = df.to_json(orient='records')

columns = [{'Header': i, 'accessor': i} for i in df.columns]

app.layout = html.Div([
    DashReactTable(
        id='table',
        data=data,
        columns=columns
    )
])

if __name__ == '__main__':
    app.run_server(debug=True)
    

DashReactTable Properties

AttributeDescriptionTypeDefault value
idOptional identifier used to reference component in callbacksstring
dataAn array of datalist of dict where each dict corresponds to a row of data
columnsAn array of column attributeslist of dict which can contain the followings keys: Header(string), accessor(string), sortable(boolean), filterable(boolean), show(boolean), width(int), minWidth(int), maxWidth(int), className(string), style(string), headerClassName(string), headerStyle(string)
showPaginationTurn on paginationbooleanfalse
showPaginationTopPut pagination on topbooleanfalse
showPaginationBottomPut pagination on topbooleantrue
showPageSizeOptionsProvide options for paginationbooleantrue
pageSizeOptionsDefine the size options for paginationlist of int5, 10, 20, 25, 50, 100
defaultPageSizeDefault page sizeint20
minRowsControls the minimum number of rows to displayint
sortableAllow columns to be sortedbooleantrue
resizableAllow columns to be resizablebooleantrue
filterableAllow columns to be filterable. The component has a custom filter which performs a case/order insensitive filter.booleanfalse
classNameAdd classname to react-table. The main use case for this is to add "-striped" and/or "-highlight"string
styleinline table stylesdict
conditionalFormattingCustom conditional color formatting. Currently only supports d3.scaleThreshold.dict with contains the following keys: domain(list of int), range(list of dict styles), ignore(list of string)

Additonal notes:

  • All column properties can override table level properties

  • To use conditional formatting you must have N + 1 range values for N domain values. Range values must be camelcased styles.

  • To make a scrolling table with fixed headers, be sure to add a fixed height to the table's style property.