Hi Isomorphic,
please see this testcase (using v10.0p_2015-05-13) and the attached screenshot:
I think that the validation error message should read something like "Please select an entry from the list" and that the entered value should not be removed (see screenshot).
If you comment out setValidateOnExit(true), edit the ComboBoxItem to "Charles Madi", switch the field, and validate via the validate-button, the edited value is not removed, which is good. The error message is still unintuitive, tough.
Best regards
Blama
please see this testcase (using v10.0p_2015-05-13) and the attached screenshot:
Code:
package com.smartgwt.sample.client; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.core.KeyIdentifier; import com.smartgwt.client.data.Criteria; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.util.PageKeyHandler; import com.smartgwt.client.util.Page; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.ComboBoxItem; import com.smartgwt.client.widgets.form.fields.TextItem; import com.smartgwt.client.widgets.layout.VLayout; public class BuiltInDS implements EntryPoint { private VLayout vL; private TestForm tF; public void onModuleLoad() { KeyIdentifier debugKey = new KeyIdentifier(); debugKey.setCtrlKey(true); debugKey.setKeyName("D"); Page.registerKey(debugKey, new PageKeyHandler() { public void execute(String keyName) { SC.showConsole(); } }); vL = new VLayout(5); vL.setPadding(20); vL.setWidth100(); vL.setHeight100(); tF = new TestForm(); IButton validate = new IButton("Validate"); validate.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { tF.validate(); } }); IButton reload = new IButton("Reload"); reload.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { vL.removeChild(tF); tF.markForDestroy(); tF = new TestForm(); vL.addMember(tF, 0); } }); vL.addMembers(tF, validate, reload); vL.draw(); } private class TestForm extends DynamicForm { public TestForm() { super(); setDataSource(DataSource.get("employees")); setAutoFetchData(false); TextItem employeeId = new TextItem("EmployeeId"); TextItem name = new TextItem("Name"); ComboBoxItemEmployee reportsTo = new ComboBoxItemEmployee("ReportsTo"); TextItem job = new TextItem("Job"); TextItem email = new TextItem("Email"); setFields(employeeId, name, reportsTo, job, email); fetchData(new Criteria("EmployeeId", "192")); } } private class ComboBoxItemEmployee extends ComboBoxItem { final private DataSource employeesDS = DataSource.get("employees"); public ComboBoxItemEmployee(String name) { super(name); setOptionDataSource(employeesDS); setValueField(employeesDS.getPrimaryKeyFieldName()); setDisplayField("Name"); setSortField("Name"); setFetchMissingValues(true); setValidateOnExit(true); setBrowserSpellCheck(false); } } }
If you comment out setValidateOnExit(true), edit the ComboBoxItem to "Charles Madi", switch the field, and validate via the validate-button, the edited value is not removed, which is good. The error message is still unintuitive, tough.
Best regards
Blama
Comment