PDA

View Full Version : Key press event in Ext.form.Panel



13 May 2014, 11:39 PM
Hi all,
I have a form panel with a lot of text fields and combo boxes.
I want to know whether the form fields are edited or not while closing.
When i press close button i should check any field values are changed or not.
I am using Ext 4.2.1

Hear is my form panel


var myPanel = Ext.create('Ext.form.Panel', {
bodyPadding: 10,
border : 0,
fieldDefaults: { msgTarget: 'side',labelAlign: 'right',labelWidth : 100},
xtype: 'container',
listeners : {

dirtychange: function( panel, dirty, eOpts ){
//alert("Changed");
}


},
items:[
{
xtype:'fieldset',
collapsible: false,
layout: 'column',
items :[{
xtype: 'container',
columnWidth:.5,
items: [
{
xtype:'datefield',
fieldLabel: 'Date',
name: 'date',
tabIndex:1,
},{
xtype:'textfield',
fieldLabel: 'Title',
name: 'title',
tabIndex:2,
maxLength:100,
enforceMaxLength:true,
},{
xtype:'textfield',
fieldLabel: 'Location',
name: 'location',
tabIndex:3,
maxLength:100,
enforceMaxLength:true,
},{
xtype:'textarea',
fieldLabel: 'Roles and Responsibilities',
name: 'requirement',
tabIndex:4,
maxLength:4000,
width:600,
height:170,
enforceMaxLength:true,
}

]
}]
}]
});

scottmartin
15 May 2014, 9:06 AM
Here is a good writeup of several options:
http://stackoverflow.com/questions/8566291/extjs-4-how-to-know-when-any-field-in-a-form-ext-form-panel-changes