I'm using material-table to create a table from an array of products. https://material-table.com/#/docs/all-props
Here is my current code.
<MaterialTable title="" style={{boxShadow: "none"}} columns={[ { title: 'Title', field: 'ProductTitle' }, { title: 'Status', field: 'Status' }, { title: 'Email', field: 'BuyerEmail' }, { title: 'ID', field: 'id' }, ]} data={this.state.ProductList} options={{ filtering: true, rowStyle: (data, index) => { if (index % 2) { return {backgroundColor: "#F8F9FC"} } } }} />
The goal is to be able to click on a row in the table and for it to link to the individual product. The URL structure of the products go as follows: mysite.com/product/id
. (The id
is the one being displayed in { title: 'ID', field: 'id' }
)
I did notice they had a prop onRowClick
and this example here https://github.com/mbrn/material-table/issues/820 . But was generating too many errors.
The goal is:
- To make each row linked to their individual URL page and to add a CSS class to hover row.
Thanks for the help.