PDA

View Full Version : DefaultWindowButtons extension



Ronaldo
18 Jan 2008, 6:33 AM
Hi all,

I just added a small window extension (http://extjs.com/learn/Extension:DefaultWindowButtons) that will add Ok and Cancel buttons to your window, and adds some standard behaviour to these buttons.
It's also possible to add only a Close butten instead of the Ok and Cancel buttons.

The plus of this is that you do not have to retype these things for every window.
Small as the extension is, IMHO it also shows how to build extensions and how to use the event handlers.

Any comments, improvements and opinions are welcome as always.

NEW
I've added some functionality and updated the page to v0.91. There's one addition I still want to make before reaching v1.0, and that is to be able to add a Select button, which will return the selected record(s) from a grid in the window. I hope to do this soon.

Enjoy,
Ronaldo

mdissel
19 Jan 2008, 2:10 PM
Nice! Two extra requests:
- the submit params should be configurable..
- add an afterClose(bool success) event..

Ronaldo
20 Jan 2008, 2:56 AM
Hi mdissel,

Thanks for your reply. I was thinking about the same functionality that you mentioned. As all my windows are separate objects, I 'initialize' the url for example in the window, cause I feel that a window has one url it should fetch all data from and save all data to.
But it should be confurable, yes, as should be the params to send with the request.

But what do you intent with the success boolean in the 'afterClose' event? I'd think that a listener can prevent closing, submitting or canceling a window by returning false. But after the this.win.close() statement, the window is always closed I'd think.

Or do you mean to pass a boolean whether or not the window is successfully submitted?

Ronaldo

mdissel
20 Jan 2008, 12:38 PM
But what do you intent with the success boolean in the 'afterClose' event? I'd think that a listener can prevent closing, submitting or canceling a window by returning false. But after the this.win.close() statement, the window is always closed I'd think.


The code that opens the window should have an option to know when the window has been closed, for example to refresh a grid. The success param will pass if the user has pressed cancel (false) or Ok (true)

Ronaldo
21 Jan 2008, 1:33 AM
Hi,

I've updated the source more or less as you asked me. There's one more thing I want to add, I'll hope to do that later on.
This morning I couln't post the new version on the wiki, as it didn't allow me to make changes to the text. I asked the ext team to update the source for me or to tell me what the error means.

I want to add another 'Select' button, which can be used together with the Close button. It's meant to return one or more selected records if the window contains a grid. This will open up the possibility of using a lookup control which will open a window and will enable the user to select a record.

Cheers
Ronaldo

Condor
21 Jan 2008, 2:18 AM
Your default onCancel and onClose handlers don't support closeAction:'hide'.

Instead of:

this.win.close();
use

this.win[this.win.closeAction]();

Ronaldo
21 Jan 2008, 3:20 AM
Hi Condor,

Thanks, I'll change that.