New:Microsoft Teams Notifications Are Now Available in Socket.Learn more →
Get Started

rc-table

Package Overview
Dependencies
Maintainers
7
Versions
461
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-table

table ui component for react

Source
npmnpm
Version
6.3.7
Version published
Weekly downloads
2.2M
-16.82%
Maintainers
7
Weekly downloads
 
Created
Source

rc-table

React table component.

NPM version build status Test coverage gemnasium deps npm download

install

rc-table

Development

npm install
npm start

Example

http://react-component.github.io/table/examples/

Usage

import Table from 'rc-table';

const columns = [{
  title: 'Name', dataIndex: 'name', key:'name', width: 100,
}, {
  title: 'Age', dataIndex: 'age', key:'age', width: 100,
}, {
  title: 'Address', dataIndex: 'address', key:'address', width: 200,
}, {
  title: 'Operations', dataIndex: '', key:'operations', render: () => <a href="#">Delete</a>,
}];

const data = [
  { name: 'Jack', age: 28, address: 'some where', key:'1' },
  { name: 'Rose', age: 36, address: 'some where', key:'2' },
];

React.render(<Table columns={columns} data={data} />, mountNode);

API

Properties

NameTypeDefaultDescription
prefixClsStringrc-table
classNameStringadditional className
idStringidentifier of the container div
useFixedHeaderBooleanfalsewhether use separator table for header. better set width for columns
scrollObject{x: false, y: false}whether table can be scroll in x/y direction, `x` or `y` can be a number that indicated the width and height of table body
expandIconAsCellBooleanfalsewhether render expandIcon as a cell
expandIconColumnIndexNumber0The index of expandIcon which column will be inserted when expandIconAsCell is false
rowKeystring or Function(record):string'key' If rowKey is string, `record[rowKey]` will be used as key. If rowKey is function, the return value of `rowKey(record)` will be use as key.
rowClassNamestring or Function(record, index, indent):stringget row's className
rowRefFunction(record, index, indent):stringget row's ref key
defaultExpandedRowKeysString[][]initial expanded rows keys
expandedRowKeysString[]current expanded rows keys
defaultExpandAllRowsBooleanfalseExpand All Rows initially
onExpandedRowsChangeFunction(expandedRows)save the expanded rows in the internal statefunction to call when the expanded rows change
onExpandFunction(expanded, record)function to call when click expand icon
expandedRowClassNameFunction(recode, index, indent):stringget expanded row's className
expandedRowRenderFunction(recode, index, indent, expanded):ReactNodeContent render to expanded row
dataObject[]data record array to be rendered
indentSizeNumber15indentSize for every level of data.i.children, better using with column.width specified
onRowClick[deprecated]Function(record, index)handle rowClick action, index means the index of current row among fatherElement[childrenColumnName]
onRowDoubleClick[deprecated]Function(record, index)handle rowDoubleClick action, index means the index of current row among fatherElement[childrenColumnName]
onRowMouseEnter[deprecated]Function(record, index)handle onRowMouseEnter action, index means the index of current row among fatherElement[childrenColumnName]
onRowMouseLeave[deprecated]Function(record, index)handle onRowMouseLeave action, index means the index of current row among fatherElement[childrenColumnName]
onRowFunction(record, index)Set custom props per each row.
onHeaderRowFunction(record, index)Set custom props per each header row.
showHeaderBooleantruewhether table head is shown
titleFunction(currentData)table title render function
footerFunction(currentData)table footer render function
getBodyWrapper[deprecated]Function(body)get wrapper of tbody, [demo](http://react-component.github.io/table/examples/animation.html)
emptyTextReact.Node or Function`No Data`Display text when data is empty
columnsObject[] The columns config of table, see table below
componentsObject Override table elements, see [#171](https://github.com/react-component/table/pull/171) for more details

Column Props

NameTypeDefaultDescription
keyStringkey of this column
classNameStringclassName of this column
colSpanNumberthead colSpan of this column
titleReact Nodetitle of this column
dataIndexStringdisplay field of the data record
widthString|Numberwidth of the specific proportion calculation according to the width of the columns
fixedString|Booleanthis column will be fixed when table scroll horizontally: true or 'left' or 'right'
alignStringspecify how content is aligned
onCellFunction(record)Set custom props per each cell.
onHeaderCellFunction(record)Set custom props per each header cell.
renderFunction(value, row, index)The render function of cell, has three params: the text of this cell, the record of this row, the index of this row, it's return an object:{ children: value, props: { colSpan: 1, rowSpan:1 } } ==> 'children' is the text of this cell, props is some setting of this cell, eg: 'colspan' set td colspan, 'rowspan' set td rowspan
onCellClick[deprecated]Function(row, event)Called when column's cell is clicked

License

rc-table is released under the MIT license.

Keywords

react

FAQs

Package last updated on 12 Oct 2018

Related posts