@trendmicro/react-table
Trend Micro Components: React Table
Last updated 6 months ago by smalltase .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @trendmicro/react-table 
SYNC missed versions from official npm registry.

react-table build status Coverage Status

NPM

React Table

Demo: https://trendmicro-frontend.github.io/react-table

Version 1.x is no longer maintained by 2019/12/06

[Friendly reminder] Please migrate to 2+ asap.

Installation

  1. Install the latest version of react and react-table:
npm install --save react @trendmicro/react-table @trendmicro/react-paginations
  1. At this point you can import @trendmicro/react-table and its styles in your application as follows:
import TableTemplate, { TableWrapper, TableHeader, TableBody, TableRow, TableCell, TableHeaderCell } from '@trendmicro/react-table';

Usage

Table Template

<TableTemplate
    hoverable
    useFixedHeader
    columns={columns}
    data={data}
    width={500}
/>

Custom render

<TableWrapper
    columns={columns}
    data={data}
    width={800}
    height={320}
>
    {({ cells, data, loader, emptyBody, tableWidth }) => {
        return (
            <Fragment>
                <TableHeader>
                    <TableRow>
                        {
                            cells.map((cell, index) => {
                                const key = `table_header_cell_${index}`;
                                const {
                                    title,
                                    width: cellWidth,
                                } = cell;
                                return (
                                    <TableHeaderCell
                                        key={key}
                                        width={cellWidth}
                                    >
                                        { title }
                                    </TableHeaderCell>
                                );
                            })
                        }
                    </TableRow>
                </TableHeader>
                <TableBody>
                    <Scrollbars
                        style={{
                            width: tableWidth
                        }}
                    >
                        {
                            data.map((row, index) => {
                                const rowKey = `table_row${index}`;
                                return (
                                    <TableRow key={rowKey}>
                                        {
                                            cells.map((cell, index) => {
                                                const key = `${rowKey}_cell${index}`;
                                                const cellValue = _get(row, cell.dataKey);
                                                return (
                                                    <TableCell
                                                        key={key}
                                                        width={cell.width}
                                                    >
                                                        { typeof cell.render === 'function' ? cell.render(cellValue, row, index) : cellValue }
                                                    </TableCell>
                                                );
                                            })
                                        }
                                    </TableRow>
                                );
                            })
                        }
                    </Scrollbars>
                </TableBody>
            </Fragment>
        );
    }}
</TableWrapper>

API

Properties

TableWrapper

Name Type Default Description
minimalist Boolean false Specify whether the table should not be bordered.
columns Object[] [] The columns config of table, see Column below for details.
data Object[] [] Data record array to be rendered.
emptyRender Function () => { return 'No Data'; } Empty content render function.
emptyText String 'No Data' The text when data is null.
height Number The height of the table.
loading Boolean false Whether table is loading.
loaderRender Function Loading content render function.
width Number(required) The width of the table.

TableHeaderCell

Name Type Default Description
width Number(required) The width of the table.

TableCell

Name Type Default Description
width Number(required) The width of the table.

TableTemplate

Name Type Default Description
minimalist Boolean false Specify whether the table should not be bordered.
columns Object[] [] The columns config of table, see Column below for details.
data Object[] [] Data record array to be rendered.
emptyRender Function () => { return 'No Data'; } Empty content render function.
emptyText String 'No Data' The text when data is null.
height Number The height of the table.
hideHeader Boolean false Whether table head is hiden.
hoverable Boolean false Whether use row hover style.
loading Boolean false Whether table is loading.
loaderRender Function Loading content render function.
useFixedHeader Boolean false Whether table head is fixed.
width Number(required) The width of the table.

Column

Name Type Default Description
title React Node or Function(): React Node Title of this column.
dataKey String Display field of the data record.
width String or Number 150 Width of the specific proportion calculation according to the width of the columns.
render Function(value, record, rowIndex) The render function of cell, has two params: the text of this cell, the record of this row, it's return a react node.

License

MIT

Current Tags

  • 0.7.4                                ...           hotfix/0.7.4 (3 years ago)
  • 2.0.2                                ...           latest (6 months ago)

49 Versions

  • 2.0.2                                ...           6 months ago
  • 2.0.1                                ...           8 months ago
  • 2.0.0                                ...           8 months ago
  • 1.0.1-alpha.2                                ...           2 years ago
  • 1.0.0-alpha.2                                ...           2 years ago
  • 1.0.1-alpha.1                                ...           2 years ago
  • 1.0.0-alpha.1                                ...           2 years ago
  • 1.0.0-alpha                                ...           2 years ago
  • 0.9.0                                ...           3 years ago
  • 0.8.4                                ...           3 years ago
  • 0.8.3                                ...           3 years ago
  • 0.8.2                                ...           3 years ago
  • 0.7.4                                ...           3 years ago
  • 0.8.1                                ...           3 years ago
  • 0.8.0                                ...           3 years ago
  • 0.7.3                                ...           3 years ago
  • 0.7.2                                ...           3 years ago
  • 0.7.1                                ...           3 years ago
  • 0.7.0                                ...           3 years ago
  • 0.6.1                                ...           3 years ago
  • 0.5.6                                ...           3 years ago
  • 0.5.5                                ...           3 years ago
  • 0.5.4                                ...           3 years ago
  • 0.5.3                                ...           3 years ago
  • 0.5.2                                ...           3 years ago
  • 0.5.1                                ...           3 years ago
  • 0.5.0                                ...           3 years ago
  • 0.4.9                                ...           3 years ago
  • 0.4.8                                ...           3 years ago
  • 0.4.7                                ...           3 years ago
  • 0.4.6                                ...           3 years ago
  • 0.4.5                                ...           3 years ago
  • 0.4.3                                ...           3 years ago
  • 0.4.2                                ...           3 years ago
  • 0.4.1                                ...           3 years ago
  • 0.4.0                                ...           3 years ago
  • 0.3.9                                ...           3 years ago
  • 0.3.8                                ...           3 years ago
  • 0.3.7                                ...           3 years ago
  • 0.3.6                                ...           3 years ago
  • 0.3.4                                ...           3 years ago
  • 0.3.3                                ...           3 years ago
  • 0.3.2                                ...           3 years ago
  • 0.3.1                                ...           3 years ago
  • 0.3.0                                ...           3 years ago
  • 0.2.2                                ...           3 years ago
  • 0.2.1                                ...           3 years ago
  • 0.2.0                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
Downloads
Today 0
This Week 2
This Month 2
Last Day 0
Last Week 1
Last Month 10
Dependencies (4)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |