I'm trying to figure a way to cancel the update of a cell, restoring the original values, if the grid header is clicked for any reason (sorting, moving, etc).
What I've attempted is trapping the MouseDown event and checking to see if the HeaderUIElement was clicked but it seems that both the BeforeExitEditMode and BeforeCellUpdate events fire as soon as the header is being clicked and before the MouseDown event fires.
I haven't found any other way of determining what is causing the BeforeCellUpdate so I could conditionally cancel the update.
Any help would be appreciated.
Regards,
Jim
BeforeCellUpdate is fired when the cell loses focus, so obviously it is before the mousedown for the header.
You can save the cell old value in the BeforeCellUpdate event, and after the mousedown restore it by setting the old value back. Just don't forget to disable the BeforeCellUpdate event when you set the value because it will fire again. You can do it with the grid EventManager.
Thanks Amiram.
I do use BeforeCellUpdate to cancel the update based on validation. However, BeforeCellUpdate knows nothing about where I clicked. I was hoping there was a way I could at least set a flag that could be checked in BeforeCellUpdate if a header was clicked.
Maybe I will have to do something like setting a flag when entering (hovering over) the HeaderUIElement and if the flag is set when BeforeCellUpdate fires, assume the header was clicked. Don't like that though because the user could have the mouse over the header and tab out of the cell.
Some more experimentation is warranted I guess :>)