1. #1
    Sencha User babbarkrishan's Avatar
    Join Date
    Oct 2009
    Location
    Chandigarh (India)
    Posts
    29
    Vote Rating
    0
    babbarkrishan is on a distinguished road

      0  

    Question How to add dynamic fields in FormPanel1

    How to add dynamic fields in FormPanel1


    Hi

    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?

    Regards
    Krishan Babbar
    KBabbar

  2. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    You need to call layout after modifing any container.

  3. #3
    Sencha User babbarkrishan's Avatar
    Join Date
    Oct 2009
    Location
    Chandigarh (India)
    Posts
    29
    Vote Rating
    0
    babbarkrishan is on a distinguished road

      0  

    Default


    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

  4. #4
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,733
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    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.

  5. #5
    Ext User
    Join Date
    Jan 2011
    Posts
    4
    Vote Rating
    0
    Alvasin is on a distinguished road

      0  

    Default


    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:

    Code:
    var newInput=document.createElement('input');
    newInput.name='myNewInput'
    document.forms.myform.appendChild(newInput);
    Here is a very basic working example:

    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script type="text/javascript">
    function add_input(){
    var newInput=document.createElement('input');
    newInput.name='myNewInput';
    document.forms.myform.appendChild(newInput);
    }
    </script>
    </head>
    <body>
    <form name="myform" action="#">
    <input type="submit" value="submit">
    <input type="text" name="art" onchange="add_input();">
    </form>
    </body>
    </html>

Similar Threads

  1. Dynamic form fields : cloning fields and fieldsets on the fly
    By arnold in forum Ext 2.x: User Extensions and Plugins
    Replies: 32
    Last Post: 17 Dec 2012, 6:58 AM
  2. add dynamic fields on the fly
    By jake2891 in forum Ext 3.x: Help & Discussion
    Replies: 13
    Last Post: 22 Jan 2010, 5:29 AM
  3. dynamic form field not display after add-remove-add
    By angelflaree in forum Ext 2.x: Help & Discussion
    Replies: 10
    Last Post: 10 Jun 2009, 12:12 PM
  4. Dynamic readOnly fields!
    By diginova in forum Ext 2.x: Help & Discussion
    Replies: 7
    Last Post: 16 May 2009, 2:33 AM
  5. Replies: 1
    Last Post: 7 Nov 2007, 8:17 AM

Thread Participants: 3

Tags for this Thread