https://github.com/jrop/react-selectable-table
https://github.com/jrop/react-selectable-table
Last synced: 25 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jrop/react-selectable-table
- Owner: jrop
- Created: 2016-05-13T22:03:55.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-09-01T17:28:29.000Z (almost 9 years ago)
- Last Synced: 2026-03-24T04:30:04.683Z (4 months ago)
- Language: JavaScript
- Size: 238 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# react-selectable-table
> A React component that allows for its rows to be selected/deselected
# Installation
```sh
npm i --save-dev react-selectable-table
```
# Demo
[Click here for a demo](https://rawgit.com/jrop/react-selectable-table/gh-pages/test/index.html)
# Use
```js
import React from 'react'
import ReactDOM from 'react-dom'
import SelectableTable from '../../src/index'
import _ from 'lodash'
class App extends React.Component {
constructor(props) {
super(props)
this.state = { selectedIndicies: [ ] }
}
onSelectionChange() {
this.setState({ selectedIndicies: this.refs.table.getSelectedIndices() })
}
render() {
return
Column 1
Column 2
Column 3
{_.range(0, 10).map(i =>
Row {i}, Column 1
Row {i}, Column 2
Row {i}, Column 2
)}
Selected Indicies: {this.state.selectedIndicies.join(', ')}
Select:
this.refs.table.setSelectedIndicies(_.range(0, 10))}>All /
this.refs.table.setSelectedIndicies()}>None
}
}
window.addEventListener('load', function () {
ReactDOM.render(, document.getElementById('react'))
})
```
# License
ISC License (ISC) Copyright (c) 2016, Jonathan Apodaca jrapodaca@gmail.com
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.