ExcelForm.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. Ext.form.ExcelForm=Ext.extend(Ext.form.FormPanel,{
  2. id: 'excelform',
  3. region: 'center',
  4. frame : true,
  5. layout : 'column',
  6. autoScroll : true,
  7. DataStoreId:null,
  8. defaultType : 'textfield',
  9. labelSeparator : ':',
  10. buttonAlign : 'center',
  11. fieldDefaults : {
  12. margin : '2 2 2 2',
  13. fieldStyle : "background:#FFFAFA;color:#515151;",
  14. focusCls: 'x-form-field-cir',//fieldCls
  15. labelAlign : "right",
  16. msgTarget: 'side',
  17. //blankText : $I18N.common.form.blankText
  18. },
  19. params: null,
  20. initComponent : function(){
  21. var id=this.DataStoreId;
  22. this.params={id:id};
  23. this.getItemsAndButtons(this, 'excel/getTemplateCondition.action', this.params );//从后台拿到formpanel的items
  24. Ext.form.ExcelForm.superclass.initComponent.call(this);
  25. },
  26. getItemsAndButtons:function(form,url,param){
  27. var me = this;
  28. Ext.Ajax.request({//拿到form的items
  29. url : basePath + url,
  30. params: param,
  31. async: false,
  32. method : 'post',
  33. callback : function(options,success,response){
  34. var res = new Ext.decode(response.responseText);
  35. if(res.exceptionInfo != null){
  36. showError(res.exceptionInfo);return;
  37. }
  38. var items=res.items;
  39. form.add(items);
  40. /* var buttons = new Array();
  41. buttons.push('->');
  42. var o = {};
  43. o.xtype = 'erpSaveButton';
  44. buttons.push(o);
  45. o.xtype='erpCloseButton';
  46. buttons.push(o);
  47. buttons.push('->');
  48. form.addDocked({
  49. xtype: 'toolbar',
  50. dock: 'bottom',
  51. defaults: {
  52. style: {
  53. marginLeft: '14px'
  54. }
  55. },
  56. items: buttons//12个加进去
  57. });*/
  58. if(res.title && res.title != ''){
  59. form.setTitle(res.title);
  60. }
  61. me.focusFirst(form);
  62. }
  63. });
  64. },
  65. focusFirst: function(form){
  66. var bool = true;
  67. Ext.each(form.items.items, function(){
  68. if(bool && this.hidden == false && this.readOnly == false && this.editable == true){
  69. this.focus(false, 200);
  70. bool = false;
  71. }
  72. });
  73. },
  74. });
  75. Ext.reg('erpExcelFormPanel', Ext.form.ExcelForm);