I have a table that has Row Selection and Cell selection set to None.
In that table I have a delete button created as an Action button. When I click it, I want to get the index of the row selected so I can delete the row.
However, I don't seem to be able to get it.
i = 0 (not sure why this doesn't work)
currentSourceRow returns me the data but not the index
In writing this I've realised I could change the currentSourceRow to include the index that I need.
However, in the interest of being able to build a generic way of doing this, it would be great to know if there is a way of getting the index of the button clicked and if not, could there be a currentSourceRowIndex (or equivalent) made available? I don't think one should need to actually "select" the row in order to locate the button clicked.
You can by using Advanced to select the row:
Thanks Scott, hadn't seen that drop down so useful to know but as I said in my post, I don't feel I should need to select the row, I just want to be able to access "i"
Does it matter if you select the row? If, for whatever reason, it does; then clear the row selection after you're done using the index value...(for now)
Sorry, yes that would be fine as a workaround. I haven't tried it but I thought it might not work well with the None setting of the table or it might flash the row selection temporarily.
I opted to add the "i" value into the original data source. I was just raising it as I felt knowing the index of the clicked button was probably common enough that a workaround shouldn't be required and if it requires a workaround, it's less intuitive for new developers.
Fair - perhaps post as a Feature request then
Deleting data by index number sounds like a bad idea. Any sorting you apply to the table may confuse everything. Can you share where you pulled the data from and what kind of deletion you want to perform?
In principle I agree with you. In this case there is no sorting but I don't think that's really the point.
The point is that I was trying to find out the row index of the button that I clicked. Whether that be for deletion or some other use case, I thought that would be possible and commonly wanted but maybe I'm wrong.
Maybe for the unintended consequence that you're highlighting they deliberately didn't allow it.
I would still like to know why the i value is always 0 though.
I think they thought selectedRow would be enough. It would be better if there is a native way to do this but if you are still willing to find the row index, the most practical solution is with the find method by any unique column.
Thanks everyone for the helpful input & solutions! We've also recorded this as a bug, so I'll post here if I get any updates