I am using DataTable component from prime-react in my React application to create a data table. The table displays rows of data corresponding to some other data displayed besides the table. My requirement is that whenever the user clicks on this other data, the corresponding row in the table (matching that data) should be highlighted. I explored the APIs given for DataTable
, and I came across filter
method which might be able to achieve this by giving me a DOM reference to the row which matches the data clicked. But I am not sure how to use the filter
method. I tried using a ref
on the DataTable
like this but it didn't work:
import React, { createRef } from "react";
const tableRef = createRef();
<DataTable
ref={tableRef}
value={props.value}
/>
tableRef.filter(); // doesn't work