-
27 Apr 2007 6:33 PM #1
FormPanel to render dynamic forms into LayoutRegions
FormPanel to render dynamic forms into LayoutRegions
Small snippet of code to render a dynamic form directly to a LayoutRegion.
After creating a dynamic form (named myForm) you can now do this:Code:var FormPanel = function(formObject) { FormPanel.superclass.constructor.call(this, Ext.id(), {autoCreate: true}); formObject.render(this.getId()); }; Ext.extend(FormPanel, Ext.ContentPanel);
Code:layout.add('west', new FormPanel(myForm))
-
29 Apr 2007 10:56 AM #2
Cannot place a title on this FormPanel ?
|[ imComplex ]|
-
30 Apr 2007 8:11 AM #3
Should be able to pass a 2nd parameter into the constructor named config then pass it up to the superclass/ContentPanel. Here is an untested fix, let me know your results:
Code:var FormPanel = function(formObject, config) { var config = config || {}; FormPanel.superclass.constructor.call(this, Ext.id(), Ext.apply({autoCreate: true}, config)); formObject.render(this.getId()); }; Ext.extend(FormPanel, Ext.ContentPanel);
-
1 May 2007 6:21 AM #4
The var config = config || {}; is giving a syntax error.
-
1 May 2007 7:17 AM #5
I'm using this code now and is working fine....
-
1 May 2007 7:39 AM #6
strange. Gave the syntax error in firefox and IE. I changed it to "var config = config;" and it works fine. Tab title is set correctly as well.
-
1 May 2007 7:45 AM #7
Just says if config was passed in as an argument set it to a variabled named config, otherwise set it to a blank object literal.Code:var config = config || {};
It could also be done like this:
Code:if (config) var config = config; else var config = {};
-
1 May 2007 10:31 AM #8
How would I go about adjusting the way the form looks in the panel? Any way to inject the html div it would have been applied to if rendered normally?
-
1 May 2007 12:17 PM #9
You would probably want to change
toCode:var config = config || {};since the the config variable is already declared as a parameter. There should be no problem with this, as I use it throughout my apps. I've seen similar stuff in the Ext code too.Code:config = config || {};
-
6 Jul 2007 6:08 AM #10
Well, I actually went back to this after not worrying about it for a long time and I guess my Ext skills must have gotten better because I figured it out pretty quickly. To set the style on the FormPanel container get the element and use setStyle. Here's mine for setting the margins for the example above:
Code:Ext.get(panel.el.dom.parentNode.id).setStyle('margin', '10px 0px 0px 10px');


Reply With Quote
