SmartGWT Pro, version 2.1
When putting two selectItems or two comboBoxItems on a form; backed by the same OptionDataSource; the data from the two selectItems/comboBoxItems interfers with each other in an unintended and unwanted fashion.
Simplified code example:
DS.xml file:
What happens:
The two selectItems/comboBoxItems render fine, and populated correctly with the values from the dataSource. Also; they display, the correctly set user (i.e. in the example, createdBy displays the full name for user "john" and assignedTo displays the full name for user "jane".)
However, when you open the drop-down, which ever selectItem/comboBoxItem is positioned SECOND in the form (in this case, assignedTo) will show the value from the FIRST dropdown as selected.
So in this case, BOTH createdBy and assignedTo show "john" as being the selected value when the dropdown is opened, even though assignedTo correctly shows "jane" as selected when the dropdown is closed.
When putting two selectItems or two comboBoxItems on a form; backed by the same OptionDataSource; the data from the two selectItems/comboBoxItems interfers with each other in an unintended and unwanted fashion.
Simplified code example:
Code:
import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.Layout; public class TomcatGWT implements EntryPoint { Layout layout; public TomcatGWT() { DataSource dataSource = DataSource.get("user"); layout= new HLayout(); layout.setWidth(800); DynamicForm form = new DynamicForm(); SelectItem createdBy = new SelectItem(); createdBy.setTitle("Created By"); createdBy.setOptionDataSource(dataSource); createdBy.setValueField("userId"); createdBy.setDisplayField("fullName"); SelectItem assignedTo = new SelectItem(); assignedTo.setTitle("Assigned To"); assignedTo.setOptionDataSource(dataSource); assignedTo.setValueField("userId"); assignedTo.setDisplayField("fullName"); createdBy.setValue("john"); assignedTo.setValue("jane"); form.setFields(createdBy, assignedTo); layout.addMember(form); } @Override public void onModuleLoad() { layout.draw(); } }
Code:
<DataSource ID="user" serverType="generic"> <fields> <field name="userId" type="text" hidden="false" primaryKey="true"/> <field name="firstName" type="text" length="255"/> <field name="lastName" type="text" length="255"/> <field name="fullName" type="text" valueXPath="concat(firstName, ' ', lastName)"/> </fields> <serverObject lookupStyle="spring" bean="userDAO"/> </DataSource>
The two selectItems/comboBoxItems render fine, and populated correctly with the values from the dataSource. Also; they display, the correctly set user (i.e. in the example, createdBy displays the full name for user "john" and assignedTo displays the full name for user "jane".)
However, when you open the drop-down, which ever selectItem/comboBoxItem is positioned SECOND in the form (in this case, assignedTo) will show the value from the FIRST dropdown as selected.
So in this case, BOTH createdBy and assignedTo show "john" as being the selected value when the dropdown is opened, even though assignedTo correctly shows "jane" as selected when the dropdown is closed.
Comment