This behaviour is causing me a problem in an application.
- Selecting a cell opens a popup where the value is entered.
- Clicking the popup's OK button saves the value in the database and updates the cell. (I'm not refreshing the binding as it can cause the row to move depending on the sort order.) The popup is then closed by the same script.
- After the popup closes it pops up again caused by the onSelectionChanged event.
Q1: Is this expected behaviour?
Q2: How would I work around it to prevent the popup opening again? I could keep track of the previous cell selection and test in the onSelectionChanged event and exit if it's the same cell. Any other ideas?
I read 'onSelectionChange' as meaning any change to the selection prop of the table. Changing the value of the data in the selected row will therefore change the data key of the selection prop.
You could probably as you say keep track of the previous cell selection and add some logic to the event script to only open the popup on cell selection change.
I am having the user click a trash can to delete a row of data. But I have the same problem as you, the first time I tested this I watched as all 6 rows below the trash can I had clicked marched up to their doom!
The only thing I have thgouht of is thqat there is data unerneath the trash can, it's an embedded view with an icon in it. I could change the value, put a change script on the data of the table, and anytime anon-zero value is detected in that column, it deletes the row.
But as I type this I realize that that will change that cell and fire the onSelectionChange again!
Hmm, if I think of something I will record it here
I have a kind of janky solution working. If I trigger on an onEditCellStart event, it doesn't care if something changes. The bad thing is the user has to double click on the trash can, and then when everything is said and done, the underlying value is showing instead of the trash can until you abort the edit.
Two questions:
- Is there a way to abort the edit in script? Even if I can I think it's still janky
- The column that I click on is all 0s. So if I delete and a new row moves up to take it's place, it is still a value of 0 so the selection change shouldn't fire. Or is it the movement of the whole table that does it?
And now that doesn't work - now the onEditCellStart is firing upon the row underneath moving up.
Oh well, quittin time, I'll try again Monday