View Full Version : handle ext.window colse(x) button

17 May 2011, 11:47 PM

i want to handle the Ext.window Close button i.e; 'x' button on top right

as to block the user to enter the fields compulsorily..

please help.....

Thank you in advance..

19 May 2011, 6:28 AM
The simplest way to deal with this issue is to set closable: false. This way a user has no choice but to use any buttons you configure in your window.

If you prefer not to take that route, then you can add a listener for the close event on the window and do anything you like, where returning false from this event will prevent the window from closing.

19 May 2011, 7:16 AM
thanks a lot friend for u reply..

i tried using listeners,but the event is not firing.

let me explain the way i used it

a page with grid and rows, on row click i need to open a pop so, i had sent the id to a showWin.js (contain all pop up windows open function) and processing it.
here i create new instance of EXT.window which opens a new view.
i had added listener in showWin.js but its not working..

thank you in advance..... :)

19 May 2011, 8:44 AM
Sorry, I goofed... I meant to say you should use the beforeclose event. Here's a brief code sample to illustrate:

var w = new Ext.Window({
height: 200,
listeners: {
beforeclose: function(panel) {
// check any logical conditions here, then
// return true to allow the window to close
// or false to keep it open.
return false;
padding: 5,
width: 300,
items: [{
html: 'Window content'
buttons: [{
text: 'Ok'
text: 'Cancel'