Announcement

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

    DynamicForms doubt

    Hello, I have a doubt about DynamicForms. I'm using SmartGWT LGPL and the problem is that I have multiple TextItem in a Window, but these fields are divided into two Layouts. To do this I had to put two DynamicForms due to Items are not added directly to the panel.
    In my application I have a DataSource bound to the two DynamicForms but when I perform fetchdata() action, these DynamicForms show all the fields contained in the Datasource.

    I have try:


    dfNForm1.setUseAllDataSourceFields(false);
    dfNForm2.setUseAllDataSourceFields(false);
    dfNForm1.setFields(getTxtCif(),getTxtName(),getTxtLastName());
    dfNForm2.setFields(getTxtEmail(),getTxtUser(),getTxtPassword());

    and then,

    dfNForm1.setDataSource(ClientDS.getInstance());
    dfNForm2.setDataSource(ClientDS.getInstance());

    But this doesn't work. Both dynamicforms show all fields.

    ----

    By other hand, I have try to bind DataSource directly to the fields:

    txtName.setOptionDataSource(ClientDS.getInstance());
    txtName.setDisplayField("name");

    But this doesn't show nothing in txtName... :(


    Can anyone help me? Thanks
    Last edited by SrArcos; 2 Jan 2011, 22:42.

    #2
    Then, Aren't there any way to do this? Because, I have the fields of my form divided in several SectionStacks, and for this reason I need use several DynamicForms (one for section). But if I need use several DataSources (one for dynamicform) when I view data on ListGrid I cannot see all datasources in this listgrid.

    Comment


      #3
      You'll need to post complete running code if you want anything but a guess. Make a small example of the problem.

      Comment


        #4
        Set the DataSource on the form first and then define the fields you want to show. You can use a ValuesManager to let multiple forms edit the same DataSource record.

        Comment


          #5
          Thank you for help me! I m going to read about ValuesManager...

          Comment


            #6
            In the same topic:

            I have read this in documentacion: "Like a DynamicForm, a ValuesManager can be databound by setting dataSource. In this case all member forms must also be bound to the same DataSource."

            Then I have done:

            Code:
            ValuesManager vm = new ValuesManager();
            
            dfNForm1.setDataSource(ClientDS.getInstance());
            dfNForm2.setDataSource(ClientDS.getInstance());
            
            vm.addMember(dfNForm);
            vm.addMember(dfNForm1);
            
            vm.setDataSource(ClientDS.getInstance());
            vm.fetchData();
            The DataSource has 6 fields: dfNform1 has 3 items associated, and dfNform2 has the 3 other. But when I say "dfNForm1.setDataSource", dfNform1 show all the DataSource's fields, although I have set setUseAllDataSourceFields to false. (The same for dfNForm2)

            Comment


              #7
              You don't show when you define the fields. See post #4 above again and then the form splitting sample.

              Comment


                #8
                Thanks for help! Here is an example of how this works. I dont like so much the file structure I have done, but it works! xD


                Edit: Anyway, I have tested doing only this:

                Code:
                vm.setDataSource(clientDS);
                ... // not doing: dfNForm.setDataSource(clientDS);
                ... // not doing: dfNForm.setValuesManager(vm);
                ... // not doing: dfNForm1.setDataSource(clientDS);
                ... // not doing: dfNForm1.setValuesManager(vm);
                
                vm.addMember(dfNForm);
                vm.addMember(dfNForm1);
                
                vm.fetchData();
                And this works fine. The key is put the "name" to the TextItem so:
                Code:
                txtID = new TextItem("id");
                Attached Files
                Last edited by SrArcos; 12 Jan 2011, 03:44.

                Comment

                Working...
                X