I’d like to add a delete icon (material/close) to a table row when it’s selected, but not sure the best method.
I thought I could use a View for the table rows which would have the columns and the delete icon within it, and only show the icon when the row is selected. However, determining if it’s selected is harder than it sounds. I’m thinking I would need to use messaging to fire a message handler whenever the table selection changes to toggle a selected state inside of each of the row views… which doesn’t sound awfully efficient.
I probably should have mentioned that the data is coming from a query which is filtered using a where clause in the query, so I can’t bind the selected row to a key value in each of the data rows which was my first thought.
Instead of a binding though, I could use a script transform on the props.data to add the selection data into each of the rows. To avoid the query running every time someone selects a row, I could bind the query to a custom prop, then bind to that prop in the props.data and apply the transform there. I did have the messaging working but it’s a bit average and will run a script for every single row - not good! I’ll move over to this instead, cheers
Though you could also add the key in the query, nothing prevents you from selecting a constant value as a column. I would still probably do it in a script transform.
The only reason I would separate the query from the transform is so that the query doesn’t have to run each time the selection is changed, otherwise i’d just combine the query and the transform
There also is rowIndex which should work with filters.
edit:
nvm its rowIndex that only checks the visilble rows, row should work then no? idk which one you need. but it doesnt rly matter if you filter or not, the selected row prop should match either rowIndex or row