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 :>)
Jim,
Have you been able to achieve what you wanted? Do you still require assistance with this case?
Michael S.
Hi Michael,
I did what I mentioned in my last post. I set a flag in the MouseEnterElement and clear it in the MouseLeaveElement. Then in the BeforeCellUpdate, if the flag is set to true, I cancel the update.
I haven't seen any problems with it so far so I guess the short answers to your questions are yes and no respectively. It would be nice in the BeforeCellUpdate to have some sort of reason property but I'm thinking that would be pretty difficult to implement.
I'll flag this post as answered.
Thanks,