Ext.form.ExcelForm=Ext.extend(Ext.form.FormPanel,{ id: 'excelform', region: 'center', frame : true, layout : 'column', autoScroll : true, DataStoreId:null, defaultType : 'textfield', labelSeparator : ':', buttonAlign : 'center', fieldDefaults : { margin : '2 2 2 2', fieldStyle : "background:#FFFAFA;color:#515151;", focusCls: 'x-form-field-cir',//fieldCls labelAlign : "right", msgTarget: 'side', //blankText : $I18N.common.form.blankText }, params: null, initComponent : function(){ var id=this.DataStoreId; this.params={id:id}; this.getItemsAndButtons(this, 'excel/getTemplateCondition.action', this.params );//从后台拿到formpanel的items Ext.form.ExcelForm.superclass.initComponent.call(this); }, getItemsAndButtons:function(form,url,param){ var me = this; Ext.Ajax.request({//拿到form的items url : basePath + url, params: param, async: false, method : 'post', callback : function(options,success,response){ var res = new Ext.decode(response.responseText); if(res.exceptionInfo != null){ showError(res.exceptionInfo);return; } var items=res.items; form.add(items); /* var buttons = new Array(); buttons.push('->'); var o = {}; o.xtype = 'erpSaveButton'; buttons.push(o); o.xtype='erpCloseButton'; buttons.push(o); buttons.push('->'); form.addDocked({ xtype: 'toolbar', dock: 'bottom', defaults: { style: { marginLeft: '14px' } }, items: buttons//12个加进去 });*/ if(res.title && res.title != ''){ form.setTitle(res.title); } me.focusFirst(form); } }); }, focusFirst: function(form){ var bool = true; Ext.each(form.items.items, function(){ if(bool && this.hidden == false && this.readOnly == false && this.editable == true){ this.focus(false, 200); bool = false; } }); }, }); Ext.reg('erpExcelFormPanel', Ext.form.ExcelForm);