1.0.3 • Published 8 years ago

table-v7 v1.0.3

Weekly downloads
6
License
-
Repository
github
Last release
8 years ago

rc-table

React table component.

NPM version build status Test coverage gemnasium deps npm download

install

Development

npm install
npm start

Example

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

Usage

import Table from 'rc-table';

const columns = [{
  title: '表头1', dataIndex: 'a', key:'a', width: 100,
}, {
  title: '表头2', dataIndex: 'b', key:'b', width: 100,
}, {
  title: '表头3', dataIndex: 'c', key:'c', width: 200,
}, {
  title: '操作', dataIndex: '', key:'d', render: () => <a href="#">操作</a>,
}];

const data = [
  { a: '123', b: '123', c: '123', key:'1' },
  { a: '123', b: '123', c: '123', key:'2' },
  { a: '123', b: '123', c: '123', key:'3' },
];

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

API

Properties

nametypedefaultdescription
prefixClsStringrc-table
classNameclassNameadditional className
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,index):string'key'If rowKey is string, record[rowKey] will be used as key. If rowKey is function, the return value of rowKey(record, index) will be use as key.
rowClassNameFunction(record,index):stringget row's className
rowRefFunction(record,index):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):stringget expanded row's className
dataObject[]data record array to be rendered
indentSizeNumber15indentSize for every level of data.i.children, better using with column.width specified
onRowClickFunction(record, index)handle rowClick action, index means the index of current row among fatherElementchildrenColumnName
columnsPageSizeNumber5pageSize of columns. (Deprecated, use fixed columns)
columnsPageRangeArraycolumns index range need paging, like 2,10. (Deprecated, use column.fixed)
showHeaderBooleantruewhether table head is shown
titleFunction(currentData)table title render function
footerFunction(currentData)table footer render function
getBodyWrapperFunction(body)get wrapper of tbody, demoe
columnsTableColumns<Object>

TableColumns

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
widthStringNumberwidth 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'
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
columnsTableColumnsdefine multiple table header

License

table-v7 is released under the MIT license.