T
TanStack3y ago
other-emerald

How to calculate a cell value that depends on other cells in the same row that are populated async?

I have a table who's cell values are calculated asynchronously. Each cell has a component which takes cares of fetching the correct data based on the accessor key. I'm now trying to add in other columns which don't do anything other than take some of those cell values and do some math on them, for example: There is a budget and a revenue column who's render value gets populated asynchronously. I want to add in a "ROI" column that should display the result of (row.revenue / row.budget) * 100. I've tried using info.row.getValue("budget") and ..("revenue") but they are undefined. The ROI cell should somehow be told to wait for the other cells to populate before rendering. Is this possible with the current API?
1 Reply
deep-jade
deep-jade3y ago
Not sure if this helps, but you can access the row using item.table.getRow(...RowID) when using the cell render method for a row. I had the requirement to get a value for the SAME row, but just in a different cell, and this worked for me. https://github.com/SeanCassiere/nv-rental-clone/blob/master/src/pages/AgreementsSearch/AgreementsSearchPage.tsx#L61-L62
GitHub
nv-rental-clone/AgreementsSearchPage.tsx at master · SeanCassiere/n...
Navotar with Tailwind and the Tanstack. Contribute to SeanCassiere/nv-rental-clone development by creating an account on GitHub.

Did you find this page helpful?