首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Ajax >

ExtJS4.x设立表单中控件为可用

2013-03-04 
ExtJS4.x设置表单中控件为可用整体代码如下所示,窗体加载的时候,4个文本框是不可用的,点击保存按钮后获得

ExtJS4.x设置表单中控件为可用
整体代码如下所示,窗体加载的时候,4个文本框是不可用的,点击保存按钮后获得窗体4个文本框可进行编辑,现在我通过下边这句获得到了窗体中4个文本框控件


var formT = this.up('form').query('textfield');

获得后进行循环,forEach如何能让formT进行单一循环

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);
                                });
                            }
                }]

            });
      });


[解决办法]
Ext.Array.forEach(formT, function(field) {
   this.setEditable= true//忘记 是什么属性可能写错了
}
[解决办法]
对控件调用 field.setVisible(true);即可

热点排行