View Full Version : Need event to detect exit tab panel

7 Oct 2010, 11:11 AM
I have a tabpanel where I dynamically add pannels which consist of a grid. I can drag elements into the grid and modify some fields in these. I can also remove elements from the grid (using rowcontextmenu). I have a button to save the changes to the grid, and want to call the same code if the user exits this panel, either by going to a different tab or navigates to some other panel. I tried to use tabchange event, but that occurs after the new tab is active and gives me ref to the new tab and the parent tabpanel, so unless I leave a flag in the parent as to where I was it doesn't do me much good.

My current strategy is to set an identifier in the parent when I enter a tab'ed panel and then use tabchange and set other events on any other possible nav event to check if the user was in one of the tab panels and then ask if he wants to save changes.

Is there some event I can monitor to cover all possibilities that isn't so low level that it will slow user response down.


7 Oct 2010, 11:14 AM
I recently tried to solve this problem in my webtop application. It can be quite tricky as you need a few pieces of information:
- what do i need to save?
- what was i trying to do?
- what to do if saving fails?

'beforetabchange' is probably what you're looking for: check if the form is dirty/valid, alert the user, return false.