Reputation: 43
I'm using this array state to render Infos on a table:
As you guys can see, i need to put a copy button on every row of the table, but i tried inserting the HTML directly to the object it self, but it failed:
What can I do to show this copy button on every row of the table?
Thanks in advance.
Upvotes: 0
Views: 924
Reputation: 13078
This:
renderCell: (ValueFormatterParams) => {
<a href="#">Oi </a>; // you are missing return statement
}
should be:
renderCell: (ValueFormatterParams) => {
return (<a href="#">Oi </a>);
}
or:
renderCell: (ValueFormatterParams) => ( <a href="#">Oi </a>)
EDIT: Getting data from row:
copyHanle = (item) => {
console.log(item);
}
//...
render() {
const columns = [
//...
renderCell: (ValueFormatterParams) => {
const {row} = ValueFormatterParams;
return (
<CopyToClipboard
text={row.name}
onCopy={() => this.setState({ copied: true })}
>
<button>Copy</button>
</CopyToClipboard>)
}
]
//...
}
See: https://material-ui.com/components/data-grid/rendering/#render-cell
Upvotes: 1