16 Nov 2010 11:03 AM #1
How to add dynamic fields in FormPanel1
I am using com.extjs.gxt.ui.client.widget.form.FormPanel for uploading a file. Now my requirement has been changed and I need to give a new option/button to user for adding more files to upload in single submit?
I tried to add a new FileUploadField() on submit of a button in my FormPanel, but it is not being added in UI.
Please help me and let me know how can I add dynamic fields in a FormPanel?
16 Nov 2010 11:05 AM #2
You need to call layout after modifing any container.
16 Nov 2010 11:26 AM #3
Thanks Sven... Its worked...
Plz suggest also, which layout to use for FormPanel or container having FormPanel so that its height get adjusted automatically by adding/removing fields dynamically?KBabbar
19 Nov 2010 12:27 PM #4
No layout which actually does any work can do that - Layout subclasses are to size their children based on the space they are given, and so cannot be told to work in the reverse way . Additionally, FormPanel has a FormLayout already - this isn't a matter of using the proper Layout, but instead how you choose to build components up after layout has occurred.
Sven's idea should work in your case, but keep in mind that using this as a general solution could be very expensive. If you want to set up multiple LayoutContainers with FormLayouts, each with this functionality, consider making a ComponentPlugin which, after render, watches for add/remove events, and fires layout on the container, or (optionally) some parent of the container, as to get all sibling components laid out correctly.
22 Jan 2011 2:10 AM #5
Once you add form elements, and if they are named, their value should be passed automatically via submission.
The best way to add form elements is via the DOM:
Here is a very basic working example:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<form name="myform" action="#">
<input type="submit" value="submit">
<input type="text" name="art" onchange="add_input();">
By arnold in forum Ext 2.x: User Extensions and PluginsReplies: 32Last Post: 17 Dec 2012, 6:58 AM
By jake2891 in forum Ext 3.x: Help & DiscussionReplies: 13Last Post: 22 Jan 2010, 5:29 AM
By angelflaree in forum Ext 2.x: Help & DiscussionReplies: 10Last Post: 10 Jun 2009, 12:12 PM
By diginova in forum Ext 2.x: Help & DiscussionReplies: 7Last Post: 16 May 2009, 2:33 AM
By jeffadams78 in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 7 Nov 2007, 8:17 AM