extjs 4 logo - ExtJS 4: show confirmation dialog before closing Tab

ExtJS 4: show confirmation dialog before closing Tab

Posted on

extjs 4 logo - ExtJS 4: show confirmation dialog before closing TabI was working on a requirement where in my TabPanel we have many tabs open parallelly. If user wants to close any if the tab, we should first ask user whether he really want to close this tab. If in the TabPanel we have only one tab remaining then we should not allow user from closing this only tab by showing error message.

ExtJS provide TabPanel where we can add Panels as an item. To implement the above requirement in ExtJS first we need to extend Panel to create a customized panel with beforeclose event. If user wants to close it, first check the number of items in current TabPanel. If item count is more than 1 then show message else show error message and return false. Returning false from beforeclose event will prevent calling close event and hence panel will not close.

Output:

When tab count is greater then 1, show confirmation message.

tab close 1 - ExtJS 4: show confirmation dialog before closing Tab

and when tab count equal to 1, show error message and return false.

tab close 2 - ExtJS 4: show confirmation dialog before closing Tab

View Online Demo

Source techzoo.org