[EXT Develop Log]--Multiple tabs in one form

Sometimes, We have a form with multiple elements, and so, put them together will show confus.

How to divide the form with tabs and  submit the button will submit the form with all tabs?

In Ext API ,I use the method "form.container()" of the form but not work great..

Finally ,I find resolve mehtod by dj in extjs forum,to extend and make tabs in ext.form,copy this extend code in ur js:

js 代码
  1. Ext.form.DialogTab = function(config){   
  2.     Ext.form.DialogTab.superclass.constructor.call(this, config);   
  3. };   
  4.   
  5. Ext.extend(Ext.form.DialogTab, Ext.form.Layout, {   
  6.     defaultAutoCreate : {tag: 'div', cls: 'x-form-ct x-dlg-tab'},   
  7.   
  8.     onRender : function(ct){   
  9.         Ext.form.Column.superclass.onRender.call(this, ct);   
  10.         if(this.title || this.legend){   
  11.             this.el.dom.title = this.title || this.legend;   
  12.         }   
  13.     }   
  14. });   
  15.   
  16. Ext.form.DialogForm = function(config){   
  17.     Ext.form.DialogForm.superclass.constructor.call(this, config);   
  18. };   
  19. Ext.extend(Ext.form.DialogForm, Ext.form.Form, {   
  20.     getDialog : function(force){   
  21.         if (force&&!this.dialog){   
  22.             this.dialog = new Ext.BasicDialog(document.body, Ext.apply({}, this, {id:Ext.id()}));   
  23.         }   
  24.         return this.dialog;   
  25.     },   
  26.     tab : function(c){   
  27.         var col = new Ext.form.DialogTab(c);   
  28.         this.start(col);   
  29.         if(arguments.length > 1){ // duplicate code required because of Opera   
  30.             this.add.apply(this, Array.prototype.slice.call(arguments, 1));   
  31.             this.end();   
  32.         }   
  33.         return col;   
  34.     },   
  35.     render : function(ct){   
  36.         Ext.form.DialogForm.superclass.render.call(this, ct);   
  37.            
  38.            
  39.         var dialog = this.getDialog(true);   
  40.   
  41.         while (this.el.dom.firstChild) {   
  42.             Ext.fly(this.el.dom.firstChild).appendTo(dialog.body);   
  43.         }   
  44.         dialog.bwrap.insertFirst(this.el.dom);   
  45.         dialog.body.appendTo(this.el);   
  46.            
  47.         if (dialog.body.child('.x-dlg-tab', true)) {   
  48.             dialog.autoTabs = true;   
  49.             dialog.body.setStyle("overflow""auto");   
  50.             dialog.initTabs();   
  51.             dialog.syncBodyHeight();   
  52.         }   
  53.            
  54.     },   
  55.     applyTo: function(dialog){   
  56.         this.dialog = dialog;   
  57.         this.render(this.getDialog(true).body);   
  58.     }   
  59. });     

So your code with dialogForm will just like:

js 代码
  1. var myForm = new Ext.form.DialogForm({   
  2.     url:'ur url',   
  3.     labelAlign: 'right',   
  4.     labelWidth: 75   
  5. });   
  6.   
  7. myForm .tab({title:"tab1"});   
  8. myForm .fieldset(...);   
  9. myForm .tab({title:"tab2"});   
  10. myForm .fieldset(...);   
  11.   
  12. var myDialog =  new Ext.BasicDialog("my-dlg", { ... });   
  13.   
  14. myForm.applyTo(myDialog );   
  15.   
  16. myDialog.show('dialog-div');  

                            

----- By   kkbear

 

你可能感兴趣的:(C++,c,prototype,ext,Opera)