ExcelForm.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. console.log(items);
  40. form.add(items);
  41. /* var buttons = new Array();
  42. buttons.push('->');
  43. var o = {};
  44. o.xtype = 'erpSaveButton';
  45. buttons.push(o);
  46. o.xtype='erpCloseButton';
  47. buttons.push(o);
  48. buttons.push('->');
  49. form.addDocked({
  50. xtype: 'toolbar',
  51. dock: 'bottom',
  52. defaults: {
  53. style: {
  54. marginLeft: '14px'
  55. }
  56. },
  57. items: buttons//12个加进去
  58. });*/
  59. if(res.title && res.title != ''){
  60. form.setTitle(res.title);
  61. }
  62. me.focusFirst(form);
  63. }
  64. });
  65. },
  66. focusFirst: function(form){
  67. var bool = true;
  68. Ext.each(form.items.items, function(){
  69. if(bool && this.hidden == false && this.readOnly == false && this.editable == true){
  70. this.focus(false, 200);
  71. bool = false;
  72. }
  73. });
  74. },
  75. });
  76. Ext.reg('erpExcelFormPanel', Ext.form.ExcelForm);