PDA

View Full Version : Extending FormPanel



tBSTAR
23 Nov 2009, 7:10 AM
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

mschwartz
23 Nov 2009, 7:16 AM
In the handler scope, "this" is the button, not the window or panel...

tBSTAR
23 Nov 2009, 8:20 AM
Indeed it is but how do I close the form?

mschwartz
23 Nov 2009, 9:09 AM
var win = new Ext.Window({
...
buttons: [
{
text: 'close',
handler: function() {
win.close();
}
}
]
});

tBSTAR
23 Nov 2009, 9:21 AM
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?


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

tBSTAR
24 Nov 2009, 10:32 AM
I couldn't find a solution the way I wanted but this is what I chose to do instead:



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



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