Skip to main content

Introducing Workflow Engine, try for FREE workflowengine.io.

Table / Data grid

Introduction​

The Table component allows users to easily create and manage tables in their applications. It provides a flexible and customizable interface that can be adapted to different needs. Using Table, you can create tables with any number of rows and columns. This component is based on Table component. This component is included within the following NPM package: @react-form-builder/components-rsuite-table.

The table consists of several types of components:

  • Column is used to display a single column of the table.
  • Column group is used to group columns.
  • Header cell is used to display the header of a table cell.
  • Cell displays the contents of the column.

Installation​

Use the following command to install the package:

npm install @react-form-builder/components-rsuite-table

Then import the stylesheet. This package does not load CSS automatically:

import '@react-form-builder/components-rsuite-table/assets/styles.css'

Connection to FormBuilder component​

The example below assumes that you also have the components from the @react-form-builder/components-rsuite package installed and the table components are additionally attached:

import {rSuiteComponents} from '@react-form-builder/components-rsuite'
import {BuilderView, FormBuilder} from '@react-form-builder/designer'
import {rSuiteTableComponents} from '@react-form-builder/components-rsuite-table'

import '@react-form-builder/components-rsuite-table/assets/styles.css'

const components = [
...rSuiteComponents,
...rSuiteTableComponents,
].map((c) => c.build())
const builderView = new BuilderView(components)

function App() {
return <FormBuilder view={builderView}/>
}

Connect to FormViewer component​

The example below shows how to connect the table components along with the @react-form-builder/components-rsuite components:

import {tableModels} from '@react-form-builder/components-rsuite-table'
import {rSuiteComponents} from '@react-form-builder/components-rsuite'
import {FormViewer, View} from '@react-form-builder/core'

import '@react-form-builder/components-rsuite-table/assets/styles.css'

const view = new View([
...rSuiteComponents.map((c) => c.build().model),
...tableModels,
])

const form = `{
"form": {
"key": "Screen",
"type": "Screen",
"props": {},
"children": [
{
"key": "table",
"type": "RsTable",
"props": {
"height": {"value": 200},
"data": {"value": [{"name": "Alex"}]}
},
"children": [
{
"key": "nameColumn",
"type": "RsColumn",
"props": {"width": {"value": 180}},
"children": [
{
"key": "nameHeader",
"type": "RsHeaderCell",
"props": {"children": {"value": "Name"}}
},
{
"key": "nameCell",
"type": "RsCell",
"props": {"dataKey": {"value": "name"}}
}
]
}
]
}
]
}
}`

function App() {
return <FormViewer view={view} getForm={() => form}/>
}

Using Table component​

The table value is an array of objects. In the viewer, a header cell shows its text, and a cell shows its child components or the value at its data key. In the designer, the table is a column grid, so you can select the table, a column, or a cell on the canvas. Row data stays off that grid until Show data in designer is on. You can place components in a cell to change what it displays. The examples below show the viewer.

Basic​

Appearance​

Loading​

Table height​

Custom cell​

Resizable​

Fluid​

Sort​

Colspan​

Rowspan​

Summary​

Show full text of cells​

Word wrap​

Properties of table components​

Table main properties​

NameTypeDescription
Affix headerbooleanAffix the table header to the specified location on the page
Affix horizontal scrollbarbooleanAffix the table horizontal scrollbar to the specified position on the page
Auto heightbooleanThe height of the table will be automatically expanded according to the number of data rows, and no vertical scroll bar will appear
BorderedbooleanShow border
Cell borderedbooleanShow cell border
DataarrayTable data
Default sort typechoiceSort type, Asc, Desc
Fill heightbooleanForce the height of the table to be equal to the height of its parent container. Cannot be used together with Auto height
Header heightnumberTable header height
HeightnumberTable height
HoverbooleanThe row of the table has a mouseover effect
LoadingbooleanShow loading
Max heightnumberMaximum height
Min heightnumberMinimum height
Row class namestringAdd an optional extra class name to row
Row heightnumberRow height
Row keystringEach row corresponds to the unique key in data
Should update scrollbooleanWhether to update the scroll after the table size is updated
Show data in designerbooleanDisplay table data on the canvas in design mode
Show headerbooleanDisplay header
Sort columnstringSort column name
Sort typechoiceSort type, Asc, Desc
VirtualizedbooleanEffectively render large tabular data
WidthnumberTable width
Word wrapchoiceWhether to appear line breaks where text overflows its content box: break-all, break-word, or keep-all

Column main properties​

NameTypeDescription
AlignchoiceAlignment, left, center, or right
Col spannumberMerges column cells to merge when the Data key value for the merged column is null or undefined
FixedbooleanFixed column
Flex grownumberSet the column width automatically adjusts, when set Flex grow cannot set Resizable and Width property
Full textbooleanWhether to display the full text of the cell content when the mouse is hovered
Min widthnumberWhen you use Flex grow, you can set a minimum width
ResizablebooleanCustomizable resize column width
Row spanfunctionMerges rows on the specified column
SortablebooleanSortable
Vertical alignchoiceVertical alignment, top, middle or bottom
WidthnumberColumn width

Column group main properties​

NameTypeDescription
AlignchoiceAlignment, left, center, or right
FixedbooleanFixed column group
Group header heightnumberThe height of the header of the merged cell group
HeaderstringGroup header
Vertical alignchoiceVertical alignment, top, middle or bottom

Header cell main properties​

NameTypeDescription
ContentstringTable column header

Cell main properties​

NameTypeDescription
Data keystringData binding key, but also a sort of key
ChildrennodeComponents rendered in the cell