0.1.4 • Published 7 years ago

react-table-vertical-heading v0.1.4

Weekly downloads
65
License
-
Repository
github
Last release
7 years ago

react-table-vertical-heading

A React component rendering a table with vertical heading with the ability to add new columns

Examples

To try this component, clone this repo and run:

npm install
npm start

Demo Image

Usage

import React, { Component } from 'react';
import VerticalTable from 'react-table-vertical-heading';

class MyComponent extends Component {
  constructor(props) {
    super(props);

    this.state = {
      heading: [],
    }

  }

  componentDidMount() {
    const heading = [
      {
        header: 'first row',
        columns: ['first column', 'second column'],
      },
      {
        header: 'second row',
        columns: ['first column', 'second column'],
      },
      {
        header: 'third row',
        columns: ['first column', 'second column'],
      },
    ]
    

    this.setState({
      heading,
    })
  }


  render() {
    return(
            <VerticalTable 
              heading={this.state.heading}
              editable={true}
            />
    )
  }
}

Props

PropertyTypeDefaultDescription
headingarray[{ header: 'first heading' },{ header: 'second heading' },{ header: 'third heading' }]An array defining the headings, and if you want to define your own columns, you can add columns to every object as in the Usage section
editablebooleantrueyou can set editable to true to make the table editable and allow columns addition, otherwise the table will be generated with the heading array you pass to the component