treetabular provides tree helpers for Reactabular. It allows you to set up collapsible rows that can contain more collapsible ones while remaining within a table format.
To achieve this, treetabular relies on a flat structure that contains the hierarchy:
If there's a parent relation, the children must follow their parent right after it (you might use fixOrder helper function if your data does not meet that criteria).
You can find suggested default styling for the package at style.css in the package root.
API
import * as tree from 'treetabular';// Or you can cherry-pickimport { filter } from 'treetabular';import { filter as filterTree } from 'treetabular';
Searches against a tree structure using operation while matching against children too. If children are found, associated parents are returned as well. This has been designed to searchtabularmultipleColumns and singleColumn, but as long as the passed operation follows the interface, it should fit in.
Allows moving tree rows while retaining given fields at their original rows. You should pass an operation that performs actual moving here. reactabular-dndmoveRows is one option.
Makes it possible to toggle node children through a user interface.
Pass "indent":false inside props object if you want to disable automatic indentation.
The default implementation of getIndex(rowData) depends on resolve.resolve as it looks for index of the row to toggle based on that. This can be customized though.
If children in your rows don't follow their parents you can use that helper method so they will be moved into right place.
Basically it converts [ parent, x, y, z, children ] into [ parent, children, x, y, z ].
Example
/*import React from 'react';import cloneDeep from 'lodash/cloneDeep';import orderBy from 'lodash/orderBy';import { compose } from 'redux';import * as resolve from 'table-resolver';import VisibilityToggles from 'reactabular-visibility-toggles';import * as Table from 'reactabular-table';import * as tree from 'treetabular';import * as search from 'searchtabular';import * as sort from 'sortabular';import { generateParents, generateRows} from './helpers';*/const schema = { type: 'object', properties: { id: { type: 'string' }, name: { type: 'string' }, age: { type: 'integer'