I use Rails and React-Table to display tables. It works fine so far. But How can one add an edit/delete column to the React-Table?
Is it even possible?
return ( <ReactTable data={this.props.working_hours} columns={columns} defaultPageSize={50} className="-striped -highlight" /> )
React Data Grid: Full Row Editing. Full row editing is for when you want all cells in the row to become editable at the same time. This gives the impression to the user that the record the row represents is being edited. To enable full row editing, set the grid option editType = 'fullRow' .
Delete row from a table, deleteRow(id), remove() or use useState () in Reactjs.
All you need to do is turn columns
into a component state. You can see a working example https://codesandbox.io/s/0pp97jnrvv
[Updated 3/5/2018] Misunderstood the question, here's the updated answer:
const columns = [ ... { Header: '', Cell: row => ( <div> <button onClick={() => handleEdit(row.original)}>Edit</button> <button onClick={() => handleDelete(row.original)}>Delete</button> </div> ) } ]
where handleEdit
and handleDelete
will be the callbacks how you want to handle the actions when the buttons are clicked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With