1.0.16 • Published 6 years ago

react-row-select-table v1.0.16

Weekly downloads
30
License
MIT
Repository
github
Last release
6 years ago

react-row-select-table

npm version

simple data table react Component

image

Installation

npm i react-row-select-table

Usage

src

import React from "react"
import Table, {Thead, Tbody, Tr, Th, Td} from "react-row-select-table"

const Custom = () =>  (
  <Table onCheck={value => console.log(value)} defaultCheckeds={[1,3]}>
    <Thead>
      <Tr>
        <Th>id</Th>
        <Th>name</Th>
      </Tr>
    </Thead>
    <Tbody>
      <Tr>
        <Td>1</Td>
        <Td>tarou</Td>
      </Tr>
      <Tr>
        <Td>2</Td>
        <Td>zirou</Td>
      </Tr>
      <Tr>
        <Td>3</Td>
        <Td>subrou</Td>
      </Tr>
    </Tbody>
  </Table>
)

Props

Table

import Table from "react-row-select-table"

render ( <Table onCheck={() => {}} defaultCheckeds={[]} >...)
nameTypedefaultDescription
onCheckfuncCallback checked indexs Signature: function(values: Array) => void
defaultCheckedsArray[]default checked indexs

Tr

import { Tr } from "react-row-select-table"

render ( <Tr isCheckRow>...)
nameTypedefaultDescription
isCheckRowbooleantrueSet the check box check box to Row

Design Customize

import React from "react"
import {BaseTable ,Thead, Tbody, Tr, Th, Td} from "react-row-select-table"
import styled from "styled-components"

const Table = styled(BaseTable)`
  table {
    width: 100%;
    border-collapse: collapse;

    tr {
      border-bottom: 1px solid #ddd;
    }

    tr.tr-body:hover {
      background-color: #f5f5f5;
    }

    tr.tr-checked {
      background-color: #f5f5f5;
    }

    th {
      padding: 0.5rem;
      text-align: left;
    }

    td {
      padding: 0.5rem;
      text-align: left;
    }
  }
`


const Custom = () =>  (
  <Table onCheck={value => console.log(value)} defaultCheckeds={[1,3]}>
    <Thead>
      <Tr>
        <Th>id</Th>
        <Th>name</Th>
      </Tr>
    </Thead>
    <Tbody>
      <Tr>
        <Td>1</Td>
        <Td>tarou</Td>
      </Tr>
      <Tr>
        <Td>2</Td>
        <Td>zirou</Td>
      </Tr>
      <Tr>
        <Td>3</Td>
        <Td>subrou</Td>
      </Tr>
    </Tbody>
  </Table>
)

DEMOS

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.9.0

6 years ago

0.5.0

6 years ago