0.8.4 • Published 4 years ago

react-vt-table v0.8.4

Weekly downloads
167
License
MIT*
Repository
github
Last release
4 years ago

React-VT-Table

Table realisation based on react-window library.

Features

  • Efficiently rendering large tables.
  • Allow custom renderers for row, cell, and header.
  • Built-in resize columns.
  • Built-in auto-scrolling.
  • Easy to add your own sorting and selecting mechanisms (see examples).
  • Works with Immutable.Iterable data lists or native arrays of objects.

Installation

npm install react-vt-table

Demo

Here are some live examples.

Examples

Check out ./src/stories folder to find some code examples.

Styling

You can use built-in CSS style:

import 'react-vt-table/dist/style.css';

or create your own using existing one

API

<Table />

Props

PropertyTypeRequired?Description
widthNumberTable width.
heightNumberTable height.
headerHeightNumber or FuncTable header height (Default: 30).
rowHeightNumber or FuncTable row height (Default: 30). Function params: (rowIndex).
dataImmutable.IterableData list for table content.
rowClassNameFuncRow className determine function. Function params: (rowIndex).
rowRendererFuncPersonal row renderer function. Function params: see <Row /> props.
sortIndicatorRendererFuncSort indicator render function. Function params: ({ dataKey, columnIndex }).
onHeaderClickFuncClick Mouse action on header row. Function params: (event, { dataKey, columnIndex }).
onHeaderDoubleClickFuncDouble Click Mouse action on header row. Function params: (event, { dataKey, columnIndex }).
onHeaderMouseOverFuncMouse Over action on header row. Function params: (event, { dataKey, columnIndex }).
onHeaderMouseOutFuncMouse Out action on header row. Function params: (event, { dataKey, columnIndex }).
onHeaderRightClickFuncRight Click Mouse action on header row. Function params: (event, { dataKey, columnIndex }).
onRowClickFuncClick Mouse action on table row. Function params: (event, { dataKey, columnIndex }).
onRowDoubleClickFuncDouble Click Mouse action on table row. Function params: (event, { dataKey, columnIndex }).
onRowMouseOverFuncMouse Over action on table row. Function params: (event, { dataKey, columnIndex }).
onRowMouseOutFuncMouse Out action on table row. Function params: (event, { dataKey, columnIndex }).
onRowMouseDownFuncMouse Down action on table row. Function params: (event, { dataKey, columnIndex }).
onRowMouseUpFuncMouse Up action on table row. Function params: (event, { dataKey, columnIndex }).
onRowRightClickFuncRight Click Mouse action on table row. Function params: (event, { dataKey, columnIndex }).
onScrollFuncAction on table scroll. Function params: See React-Window's docs.
onResizeColumnFuncAction on change column width. Function params: ({ dataKey, columnIndex, resizeDiff, newWidth }).
overflowWidthNumberWidth of vertical table overflow.
minColumnWidthNumberMinimal column width.
maxColumnWidthNumberMaximum column width.
dynamicColumnWidthBoolDynamic width for columns that was not resized.
listPropsObjectProps for inner react-window list component. @see See React-Windows docs
noItemsLabelNodeNo items in data list label.
disableHeaderBoolHide table header row.
autoScrollBoolAuto scroll to list bottom.
classNameStringOptional custom CSS class name to attach to root container element.
idStringOptional custom id to attach to root container element.

Methods

scrollTo(scrollOffset: number): void

scrollToItem(index: number, align: string = "auto"): void

For more info see React-Window's docs

<Column />

Props

PropertyTypeRequired?Description
cellRendererFuncContent cell render function. Function params: ({ dataKey, rowData, columnIndex }).
columnHeaderCellRendererFuncColumn header cell render function. Function params: ({ label, dataKey, columnIndex }).
dataKeyStringField key containing data.
widthNumberDefault column width in pixels.

<Row />

Use Row component only if you want to low modify your table rows. (See example ./srs/stories/rowRenderer.js)

Props

PropertyTypeRequired?Description
indexNumberRow number
styleObjectRow style
dataObjectAdditional row data ({dataList, rowProps}) where dataList is table data and rowProps is additional row properties (see below)

Additional row properties

Additional row properties are contained in row's props.data.rowProps

PropertyTypeRequired?Description
columnsarrayTable columns array
rowClassNameFuncRow className determine function. Function params: (rowIndex).
getRowWidthFuncGet row actual width.
getDataRowItemFuncFunction to get cell value. Function params: ({rowData, dataKey}).
getColumnWidthFuncFunction to get column width. Function params: (columnIndex).
getDataRowFuncFunction to get row data item. Function params: (rowIndex).
onClickFunconClick row handler. Function params: (event, { dataKey, columnIndex }).
onDoubleClickFunconDoubleClick row handler. Function params: (event, { dataKey, columnIndex }).
onMouseOverFunconMouseOver row handler. Function params: (event, { dataKey, columnIndex }).
onMouseOutFunconMouseOut row handler. Function params: (event, { dataKey, columnIndex }).
onRightClickFunconRightClick row handler. Function params: (event, { dataKey, columnIndex }).

License

MIT © avin

0.8.4

4 years ago

0.8.3

5 years ago

0.8.2

5 years ago

0.8.1

5 years ago

0.8.0

5 years ago

0.7.0

5 years ago

0.6.7

5 years ago

0.6.6

5 years ago

0.6.5

5 years ago

0.6.4

5 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.0

5 years ago

0.4.1

5 years ago

0.4.0

6 years ago

0.3.20

6 years ago

0.3.19

6 years ago

0.3.18

6 years ago

0.3.17

6 years ago

0.3.16

6 years ago

0.3.15

6 years ago

0.3.14

6 years ago

0.3.13

6 years ago

0.3.12

6 years ago

0.3.11

6 years ago

0.3.10

6 years ago

0.3.9

6 years ago

0.3.8

6 years ago

0.3.7

6 years ago

0.3.6

6 years ago

0.3.5

6 years ago

0.3.4

6 years ago

0.3.3

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago