ext动态新增一行

ext 动态 新增行 新增一行(1)
-------------------------------------------------------------------------------------------
var additional_AddOrgFrame = function(map){
    //自定义参数
    var id = 0;
    //编码方式
    Ext.lib.Ajax.defaultPostHeader += '; charset=utf-8';
    //使用表单提示
    Ext.QuickTips.init();
    Ext.form.Field.prototype.msgTarget = 'side';
    // 添加按钮
    var newDept_action = new Ext.Action({
        cls: 'x-btn-text-icon bmenu',
        icon: pageContextRequestContextPath + '/ext/images/menu-show.gif',
        text: '添加新的部门(新的一行)',
        handler: function(){
            id = id + 1;
           
            //添加新的fieldSet
            var org_fieldSet = new Ext.Panel({
           
                //column布局控件开始
               
                id: 'org_fieldSet_' + id,
                layout: 'column',
                border: false,
                items: [//组件开始
                {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [{
                        //为空
                        blankText: '组织名称不能为空',
                        emptyText: '',
                       
                       
                        editable: false,
                        triggerAction: 'all',
                        allowBlank: false,
                        //为空
                       
                        xtype: 'textfield',
                        fieldLabel: '组织名称',
                        id: 'org_field_orgName_' + id,
                        name: 'org_field_orgName_' + id,
                        anchor: '90%'
                   
                    }]
                } //组件结束
, //组件开始
                {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [{
                        //为空
                        blankText: '上级部门不能为空',
                        emptyText: '',
                       
                       
                        editable: false,
                        triggerAction: 'all',
                        allowBlank: false,
                        //为空
                       
                        xtype: 'textfield',
                        fieldLabel: '上级部门',
                        id: 'org_field_orgParent_' + id,
                       
                        anchor: '90%'
                   
                   
                    }]
                } //组件结束
, //按钮开始
                {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [{
                   
                        xtype: 'button',
                        text: '选择上级部门',
                        scope: this,
                        handler: function(){
                       
                       
                       
                       
                        }
                    }]
                } //按钮结束
, //组件开始
                {
               
               
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [{
                        //为空
                        blankText: '上级部门不能为空',
                        emptyText: '',
                       
                       
                        editable: false,
                        triggerAction: 'all',
                        allowBlank: false,
                        //为空
                        //xtype: 'hidden',
                        xtype: 'textfield',
                        fieldLabel: '本部门ID',
                       
                        value: 'org_field_orgId_' + id,
                        anchor: '90%'
                   
                   
                    }]
                } //组件结束
, //按钮开始
                {
                    columnWidth: .2,
                    layout: 'form',
                    border: false,
                    items: [{
                   
                        xtype: 'button',
                        text: '删除',
                        value: id,
                        scope: this,
                       
                       
                        handler: function(obj){
                            var del_id = obj.value;
                            //var field_1 = Ext.getCmp('org_field_orgName_' + del_id);
                            var fieldSet_1 = Ext.getCmp('org_fieldSet_' + del_id);
                            //删除一行
                            simple.remove(fieldSet_1, true);
                           
                        }
                    }]
                } //按钮结束
]
           
                //column布局控件结束
            });
            //添加fieldSet
            simple.add(org_fieldSet);
            //重新剧新
            simple.doLayout();
           
        },
        iconCls: 'blist'
    });
    var first_Org_fieldSet = new Ext.Panel({
   
        //column布局控件开始
       
        id: 'org_fieldSet_' + id,
        layout: 'column',
        border: false,
        items: [//组件开始
        {
            columnWidth: .2,
            layout: 'form',
            border: false,
            items: [{
                //为空
                blankText: '组织名称不能为空',
                emptyText: '',
               
               
                editable: false,
                triggerAction: 'all',
                allowBlank: false,
                //为空
               
                xtype: 'textfield',
                fieldLabel: '组织名称',
                id: 'org_field_orgName_' + id,
                name: 'org_field_orgName_' + id,
                anchor: '90%'
           
            }]
        } //组件结束
, //组件开始
        {
            columnWidth: .2,
            layout: 'form',
            border: false,
            items: [{
                //为空
                blankText: '上级部门不能为空',
                emptyText: '',
               
               
                editable: false,
                triggerAction: 'all',
                allowBlank: false,
                //为空
               
                xtype: 'textfield',
                fieldLabel: '上级部门',
                id: 'org_field_orgParent_' + id,
               
                anchor: '90%'
           
           
            }]
        } //组件结束
, //按钮开始
        {
            columnWidth: .2,
            layout: 'form',
            border: false,
            items: [{
           
                xtype: 'button',
                text: '选择上级部门',
                scope: this,
                handler: function(){
               
               
               
               
                }
            }]
        } //按钮结束
, //组件开始
        {
       
       
            columnWidth: .2,
            layout: 'form',
            border: false,
            items: [{
                //为空
                blankText: '上级部门不能为空',
                emptyText: '',
               
               
                editable: false,
                triggerAction: 'all',
                allowBlank: false,
                //为空
                //xtype: 'hidden',
                xtype: 'textfield',
                fieldLabel: '本部门ID',
               
                value: 'org_field_orgId_' + id,
                anchor: '90%'
           
           
            }]
        } //组件结束
, //按钮开始
        {
            columnWidth: .2,
            layout: 'form',
            border: false,
            items: [{
           
                xtype: 'button',
                text: '删除',
                value: id,
                scope: this,
               
               
                handler: function(obj){
                    var del_id = obj.value;
                    //var field_1 = Ext.getCmp('org_field_orgName_' + del_id);
                    var fieldSet_1 = Ext.getCmp('org_fieldSet_' + del_id);
                   
                   
                   
                    simple.remove(fieldSet_1, true);
                   
                   
                   
                }
            }]
        } //按钮结束
]
   
        //column布局控件结束
    });

你可能感兴趣的:(Ajax,ext,prototype)