Results 1 to 6 of 6

Thread: Extending FormPanel

  1. #1
    Sencha User
    Join Date
    Jul 2008
    Location
    Brooklyn NY
    Posts
    120

    Default Extending FormPanel

    Hi,

    I am extending a formpanel with a cancel button that will be called from extended window. How do I close the window by clicking the cancel button?

    {
    text: 'Cancel',
    handler: function(){
    this.close(); //<-- This doesn't work
    }

    Thanks

  2. #2
    Sencha User mschwartz's Avatar
    Join Date
    Nov 2008
    Location
    San Diego, Peoples' Republic of California
    Posts
    2,061

    Default

    In the handler scope, "this" is the button, not the window or panel...

  3. #3
    Sencha User
    Join Date
    Jul 2008
    Location
    Brooklyn NY
    Posts
    120

    Default

    Indeed it is but how do I close the form?

  4. #4
    Sencha User mschwartz's Avatar
    Join Date
    Nov 2008
    Location
    San Diego, Peoples' Republic of California
    Posts
    2,061

    Default

    Code:
    var win = new Ext.Window({
     ...
     buttons: [
       {
          text: 'close',
          handler: function() {
            win.close();
          }
        }
      ]
    });

  5. #5
    Sencha User
    Join Date
    Jul 2008
    Location
    Brooklyn NY
    Posts
    120

    Default

    This is my window code adding the form panel. I put the button on the formpanel so I can use validation. Now, I can move the button to the window in the code below and handle the validation manually. But the question still remain, to close or not to close?

    Code:
    Application.TransactionWindow = Ext.extend(Ext.Window, {
         border:false
        ,initComponent:function() {
            Ext.apply(this, {
                                    title: 'Add New',
                                    width: 800,
                                    height:600,
                                    layout: 'fit',
                                    modal: true,
                                    bodyStyle:'padding:5px;',
                                    items: [{xtype:'transactionPanel'}]
            });
     
            Application.TransactionWindow.superclass.initComponent.apply(this, arguments);
        } // eo function initComponent
     
        ,onRender:function() {
           //this.store.load();
     
            Application.TransactionWindow.superclass.onRender.apply(this, arguments);
        } // eo function onRender
    });
    
    Ext.reg('transactionWindow', Application.TransactionWindow);
    Thanks

  6. #6
    Sencha User
    Join Date
    Jul 2008
    Location
    Brooklyn NY
    Posts
    120

    Thumbs up

    I couldn't find a solution the way I wanted but this is what I chose to do instead:

    Code:
    var winClient = new Application.TransactionWindow();
    var frmClient = winClient.getComponent('frmClient');
    This is how I added my buttons:

    Code:
    frmClient.addButton({
                        text: 'Cancel',
                        handler: function(){
                                winClient.close();
                        }
    })

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •