1. #1
    Sencha User Ronaldo's Avatar
    Join Date
    Jul 2007
    Location
    Enschede, The Netherlands
    Posts
    291
    Vote Rating
    0
    Ronaldo is on a distinguished road

      0  

    Default DefaultWindowButtons extension

    DefaultWindowButtons extension


    Hi all,

    I just added a small window extension 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
    Last edited by Ronaldo; 22 Jan 2008 at 11:20 PM. Reason: new version

  2. #2
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    NL
    Posts
    608
    Vote Rating
    1
    mdissel is on a distinguished road

      0  

    Default


    Nice! Two extra requests:
    - the submit params should be configurable..
    - add an afterClose(bool success) event..

  3. #3
    Sencha User Ronaldo's Avatar
    Join Date
    Jul 2007
    Location
    Enschede, The Netherlands
    Posts
    291
    Vote Rating
    0
    Ronaldo is on a distinguished road

      0  

    Default


    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

  4. #4
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    NL
    Posts
    608
    Vote Rating
    1
    mdissel is on a distinguished road

      0  

    Default


    Quote Originally Posted by Ronaldo View Post
    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)

  5. #5
    Sencha User Ronaldo's Avatar
    Join Date
    Jul 2007
    Location
    Enschede, The Netherlands
    Posts
    291
    Vote Rating
    0
    Ronaldo is on a distinguished road

      0  

    Default


    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

  6. #6
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    94
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Your default onCancel and onClose handlers don't support closeAction:'hide'.

    Instead of:
    Code:
    this.win.close();
    use
    Code:
    this.win[this.win.closeAction]();

  7. #7
    Sencha User Ronaldo's Avatar
    Join Date
    Jul 2007
    Location
    Enschede, The Netherlands
    Posts
    291
    Vote Rating
    0
    Ronaldo is on a distinguished road

      0  

    Default


    Hi Condor,

    Thanks, I'll change that.

Thread Participants: 2