Magic Table

MagicTable is a helper component for easily and quickly making tables with built-in selectors and expansion, and (in the future) windowing/virtualization.

Under the surface it uses the <Table*> classes documented in the table pages.

MagicTable is still work in progress. Planned to do at some point is:

How to use

Simple table

To create a table, you need two things:

Headers

headers defines the columns that MagicTable will render. It is an array of objects:

By default the header key is used to extract data from the row data, so with the headers above and the following data:

MagicTable will render

PRO TIP: MagicTable uses the lodash ‘get’ method to get the cell value, so use can use paths to get properties from deeper in your data structure, for instance you can use error.message as a header key.

Custom cell renderers

Renderers are used to customize cell rendering, if you wish to do more than simple render a text value in a cell.

The renderers prop is an object that maps a renderer to a header key. In this example we’ve defined a renderer for the ‘type’ cell.

The renderer must be a functional component. It should return a table cell; using the <TableCell> component is a good idea but not mandatory.

The renderer will receive props containing:

Example

Expansion

MagicTable has build in accordion / drawer / expandable row functions.

To enable expansion, set the property expandable to true and add an expandedRowRenderer functional component.

ExpandedRowRenderer

A function component render prop that receives the following props:

Selection

MagicTable has build in selectors. To enable selection:

Search Gunnel

Powered byAlgolia