a surveymonkey react table component
$ npm install --save sm-react-table- selection (with selection column)
- context menu on rows
- custom column formatters (renderers)
columnsan array of column objects
// a column object
{
name: "AGE", // name/id of column
title: "Age", // displayed text for column
width: 160, // width of the column
render: (r) => <a href='/test'>r</a> // custom render function for the column
}rowsan array of objects their keys corresponding to the names of the columns
// a corresponding row object for the above column example
{
"AGE": '50'
}widthwidth of the tableheightheight of the tableselectionEnabledenable selectionselectedSMTableSetobject to use to store the selected rowsselectionColumnEnabledrender the selection columnonSelectionChangecallback for when the selection changesmenuEnabledenable the use of a menu for row clickmenua menu to use
// example menu (requires smlib-ui)
[
{
item: <span>
<span className='smf-icon smtable-icon'>W</span>
Edit
</span>,
action: CONTEXT_MENU_ACTIONS.EDIT,
onClick: (e, data) => console.log(data)
},
{
item: <span>
<span className='smf-icon smtable-icon'>#</span>
Delete
</span>,
action: CONTEXT_MENU_ACTIONS.DELETE,
onClick: (e, data) => console.log(data)
}
]to use sm-react-table in your project (using ES6 imports)
import { SMTable } from 'sm-react-table'
// ...
<SMTable rows={...} columns={...}/>see basic_example.js
see a full-fledged instance of sm-react-table in the responsestable project
