Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    controlling dynamic form layout

    Hello,

    We want to control the automatic layout of a form.
    We don't want to control each field of the form manually.

    We want to change this behaviour:

    Code:
    DynamicForm form = new DynamicForm();
    form.setNumCols(4);
    form.setDataSource(ds);
    This gives us what we need, but instead of the default left to right layout, we want the 2nd field to be put in the 1st column under the 1st field.
    So for 5 datasource fields we would get
    field1 | field4
    field2 | field5
    field3 |


    Our datasources are filled up dynamically, so we don't know how many fields will follow, so we can't hardcode this layout.

    The interface FormLayout doesn't get me much wiser... what exactly happens when calling the code above? Where do the forms get layout left to right, etc?

    We came across setItemLayout() on DynamicForm. Do we have to implement our own FormLayoutType ?


    I guess ultimately we could split the 1 form over 2 forms, and put them next to each other. But is that a good approach..

    thanks for the input

    #2
    In my situation, as I need to add fields on the fly, remove, reorder them I ended up having one dynamic form for every field on a VLayout. When needed I link them together with a ValuesManager.
    This way the DynamicForm acts like a wrapper for a TextItem on the VLayout.

    Don't know if is the best way to do it but it get's much flexibility on the layout side, not to mention if I end up switching the parent VLayout with a portal for example.

    Comment


      #3
      You should look into FormLayout: http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/docs/FormLayout.html

      Comment


        #4
        Ignore my above comment. It appears that this is just a writeup. What a way to abuse javadocs :(

        Comment


          #5
          Is there a way to do what's asked in this thread?

          Specifically I want to add fields like this...
          field1 | field4
          field2 | field5
          field3 |

          Especially since I want the fields in the ds.xml file ordered in this way to then show in the same order for grids. The default layout of ...
          field 1 | field 2
          field 2 | field 3
          field 4 |
          ...is not what I want, so I have to choose between grid and form layout sequence.

          thanks!
          chris

          Comment


            #6
            Yes, you just use setFields() with the items in the order you want. This overrides DataSource order. See the QuickStart Guide, Data Binding chapter.

            Comment


              #7
              OK. I was hoping I could just give the names of the fields or something. But that's really minor. ... setFields() works fine.

              Thanks!
              chris

              Comment


                #8
                Because of the facilities discussed in the Data Binding chapter, the names of the fields is really the only information you need to provide (the rest comes from the DataSource).

                Comment


                  #9
                  When you have each item in it's own DynamicForm (so you can do actual page layout using HLayout and VLayout) do you get a fetch per item or does the client side cache the data?

                  Comment


                    #10
                    Not sure we understand the question, but valuesManager.fetchData() would result in just one fetch even with multiple forms involved.

                    Comment

                    Working...
                    X