0.0.4 • Published 2 years ago

@kavience/react-table v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Introduction

A react table UI component.

Demo

View Demo

Usage

npm install @kavience/react-table

Easy use

import React from 'react';
import ReactTable from '@kavience/react-table';

const columns: any[] = [
  {
    title: '姓名',
    align: 'center',
    width: 120,
    ellipsis: true,
    dataIndex: 'name'
  },
  {
    title: '年龄',
    dataIndex: 'age'
  },
  {
    title: '身高',
    dataIndex: 'height'
  },
  {
    title: '体重',
    dataIndex: 'weight'
  }
];

const EasyUse = () => {
  const dataSource = [
    {
      id: 1,
      name:
        'kevinkevinkevinkevinkevikevinkevinkevinkevinkevinkevinkevinkevinkevinkevinn',
      age: 28,
      height: '168cm',
      weight: '75kg'
    },
    {
      id: 2,
      name: 'kevin2',
      age: 28,
      height: '168cm',
      weight: '75kg'
    },
    {
      id: 3,
      name: 'kevin3',
      age: 28,
      height: '168cm',
      weight: '75kg'
    }
  ];
  
  return (
    <div>
      <h2>Use React Table Simply</h2>
      <ReactTable
        size="mini"
        bordered
        rowKey="id"
        columns={columns}
        dataSource={dataSource}
      />
    </div>
  );
};

export default EasyUse;

Api

Table

PropertyDescriptionTypeDefaultVersion
columnsTable coulmnsColumn[][]0.0.1
dataSourceTable data sourceany[][]0.0.1
borderedShow border or notbooleanfalse0.0.1
rowKeyRow's unique keystring'key'0.0.1
sizeTable size'mini' | 'small' | 'middle' | 'large''middle'0.0.1
headerTable headerany0.0.1
footerTable footerany0.0.1
paginationPaginationPaginationProps0.0.1
localeLanguage localeReactTableLocal0.0.1
onChangeTable change(pagination?: any, filters?: any, sorter?: any) => any;0.0.1

Column

PropertyDescriptionTypeDefaultVersion
keyUnique key of this column, you can ignore this prop if you've set a unique dataIndexstring0.0.1
dataIndexDisplay field of the data recordstring0.0.1
titleColumn titlestring0.0.1
alignThe specify which way that column is aligned\'left' | 'right' | 'center'0.0.1
widthTable Widthnumber | string0.0.1
ellipsisThe ellipsis cell content, not working with sorter and filters for now.booleanfalse0.0.1
hiddenHidden this columnbooleanfalse0.0.1
classNameColumn classstring0.0.1
onFilterColumn on filter(value: string, record: any) => boolean;0.0.1
sorterColumn Sorter((firstRecord: any, secondRecord: any) => any) | boolean;0.0.1

Thanks