Thursday, May 22, 2008

Using listener to update Window shadow

This is an update to my earlier post on fixing Window with closable fieldset. My earlier approach is to use event after creating the Window. The better and shorter approach is to make use of listener.

So instead of :

      Ext.getCmp('formfieldset').on("collapse", function() {
console.log("[fieldset] resize -- sync");
win.syncShadow();
}, this)
We can just do this:

form = new Ext.FormPanel({
labelWidth: 75, // label settings here cascade unless overridden
url:'save-form.php',
frame:true,
bodyStyle:'padding:5px 5px 0',
width: 350,
autoHeight:true,
defaults: {width: 240},
defaultType: 'textfield',
items :[{
fieldLabel: 'Full Name',
name: 'fullname',
allowBlank:false
},{
fieldLabel: 'Company',
name: 'company'
},{
xtype:'fieldset',
id:'formfieldset',
title: 'Contact',
collapsible: true,
autoWidth:true,
autoHeight:true,
defaults: {width: 220},
defaultType: 'textfield',
items :[{
fieldLabel: 'Email',
name: 'email'
},{
fieldLabel: 'Phone No#',
name: 'mobile'
}
]
}],
listeners:{
collapse:function(panel) {
this.syncShadow();
},
scope:this
}
});

No comments: