ExtJS4.x设置表单中控件为可用
整体代码如下所示,窗体加载的时候,4个文本框是不可用的,点击保存按钮后获得窗体4个文本框可进行编辑,现在我通过下边这句获得到了窗体中4个文本框控件
var formT = this.up('form').query('textfield');
Ext.Array.forEach(formT, function(field) {
然后在这里对获得到的那个textfield控件进行可用设置
}
Ext.onReady(function(){
var formPanel;
formPanel = Ext.widget('form', {
renderTo: Ext.getBody(),
title: 'Complete Check Out',
frame: true,
width: 550,
bodyPadding: 5,
fieldDefaults: {
labelAlign: 'right',
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
// Billing Address
{
xtype: 'fieldset',
title: 'Billing Address',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'checkbox',
name: 'billingSameAsMailing',
boxLabel: 'Same as Mailing Address?',
hideLabel: true,
checked: true,
style: 'margin-bottom:10px',
}, {
xtype: 'textfield',
fieldLabel: 'Street Address',
name: 'billingStreet',
disabled: true
}, {
xtype: 'container',
layout: 'hbox',
items: [{
xtype: 'textfield',
fieldLabel: 'City',
name: 'billingCity',
disabled: true
}, {
xtype: 'combobox',
name: 'billingState',
fieldLabel: 'State',
labelWidth: 50,
width: 100,
disabled: true
}, {
xtype: 'textfield',
fieldLabel: 'Postal Code',
labelWidth: 80,
name: 'billingPostalCode',
width: 160,
disabled: true
}]
}]
},
],
buttons: [{
text: '新建',
id:'InsertId',
handler: function() {
this.up('form').getForm();
var insertID = Ext.getCmp('InsertId');
var editID = Ext.getCmp('EditId');
var saveID = Ext.getCmp('SaveId');
insertID.hide();
editID.hide();
saveID.show();
}
}, {
text:'修改',
id:'EditId',
handler:function(){
}
},{
text: '保存',
xtype:'button',
width: 150,
hidden:true,
id:'SaveId',
handler: function(c) {
var formT = this.up('form').query('textfield');
Ext.Array.forEach(formT.up('form').query('textfield'), function(field) {
//formT.setDisabled(disabled);
alert(formT);
});
}
}]
});
});