Finding a row with a given cell value inside a table component

Hi,

This is probably something very simple, but I just couldn't find the way to do this.

Basically I know the information from one of the cells and I would like to find the row which contains the given cell value, then access another cell of the same row. I guess if I could get the index of that row somehow that would help me a lot.

If this info helps: the table is based on a Google Sheets query and the values I know are unique ones (product IDs) so always there will be just 1 search result.

Hello @Istvan ,

This is dependent on how the structure of the data you are trying to go through.

if it is an array, I would use the findIndex method.

Here is a screenshot of the structure of the data I am trying to go through [1], where the data is located within my table [2] and the code which shows the result and all the data corresponding to that row.

let tableData = companiesQuery.data;
const rowIndex = tableData.findIndex(row => row.email === "pathway.consultancy@tryretool.com");

return tableData[rowIndex];

Hello,

I tried this method but I keep getting the error 'tableData.findIndex is not a function'.

Is there something I am perhaps missing here?

Thanks!

Hey @bg1900!

What is the analog of companiesQuery.data returning for you? If it's a SQL query then let tableData = formatDataAsArray(companiesQuery.data) may work. Some APIs have more complex data structures though. If you could share roughly what you're getting back that might help!

1 Like