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… :frowning:

Can anyone help me? Thanks

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.

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

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.

Thank you for help me! I m going to read about ValuesManager…

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:

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)

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

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:

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:

txtID = new TextItem("id");

FrmValuesManager.java (5.6 KB)