Hallo,
I'm having problems with the automatically generated isOneOf validator of a DataSourceEnumField.
In my case, I have a ListGrid with an associated DynamicForm to enter the data. One field is a DataSourceEnumField with an OptionDataSource bound to it. The EnumField and the OptionDataSoruce create a SelectItem with the valid values for this field. Because the user can't enter an other (wrong) value there, I wouldn't need client side validation at all for this field. And because I'm using a REST DataSource, I must handle the server side validation my self.
But so far, I couldn't find out, how to get rid of the automatically created isOneOf validator and get the following WARNs in the Developer Console:
and
So, is there a way to disable the isOneOf validator or let it take the valueMap from the OptionDataSource? Or is there maybe some other trick?
The following sample code reproduces my problem using the datasources from the showcase.
Thanks in advance
Christian
PS: I'm using SmartGWT 4.0.
I'm having problems with the automatically generated isOneOf validator of a DataSourceEnumField.
In my case, I have a ListGrid with an associated DynamicForm to enter the data. One field is a DataSourceEnumField with an OptionDataSource bound to it. The EnumField and the OptionDataSoruce create a SelectItem with the valid values for this field. Because the user can't enter an other (wrong) value there, I wouldn't need client side validation at all for this field. And because I'm using a REST DataSource, I must handle the server side validation my self.
But so far, I couldn't find out, how to get rid of the automatically created isOneOf validator and get the following WARNs in the Developer Console:
Code:
16:49:11.194 [ERROR] [testcase.Showcase] 16:49:11.195:XRP3:WARN:validation:isOneOf validator specified with no specified list of options or valueMap - validator will always fail. Field definition:{name: "employeeId", type: "enum", _typeDefaultsAdded: true, _simpleType: Obj{name:enum}, validators: Array[1], title: "Employee Id", _titleAutoDerived: true}
Code:
16:49:11.210 [ERROR] [testcase.Showcase] 16:49:11.196:XRP3:WARN:DataSource:isc_DataSource_0:isc_DataSource_0.employeeId: value: "4" failed on validator: {type: "isOneOf", _generated: true, defaultErrorMessage: "Not a valid option"}
The following sample code reproduces my problem using the datasources from the showcase.
Code:
package testcase.client; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.fields.DataSourceEnumField; import com.smartgwt.client.data.fields.DataSourceIntegerField; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.FormItem; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.events.RecordClickEvent; import com.smartgwt.client.widgets.grid.events.RecordClickHandler; import com.smartgwt.client.widgets.layout.VLayout; public class FormGridValidation extends VLayout { private DataSource mainDS; private DataSource optionDS; private DynamicForm form; private ListGrid grid; public FormGridValidation() { mainDS = new DataSource(); mainDS.setRecordXPath("/List/teamMember"); DataSourceTextField dsfProjectCode = new DataSourceTextField("projectCode"); DataSourceEnumField dsfEmployee = new DataSourceEnumField("employeeId"); mainDS.setFields(dsfProjectCode, dsfEmployee); mainDS.setDataURL("ds/test_data/teamMembers.data.xml"); optionDS = new DataSource(); optionDS.setRecordXPath("/List/employee"); optionDS.setDataURL("ds/test_data/employees.data.xml"); DataSourceIntegerField dsfOptionEmployeeId = new DataSourceIntegerField( "EmployeeId"); dsfOptionEmployeeId.setPrimaryKey(true); DataSourceTextField dsfOptionEmployeeName = new DataSourceTextField( "Name"); optionDS.setFields(dsfOptionEmployeeId, dsfOptionEmployeeName); form = new DynamicForm(); form.setDataSource(mainDS); FormItem item = form.getItem("employeeId"); item.setOptionDataSource(optionDS); item.setValueField("EmployeeId"); item.setDisplayField("Name"); grid = new ListGrid(); grid.setWidth(800); grid.setHeight(400); grid.setDataSource(mainDS); grid.setAutoFetchData(true); grid.addRecordClickHandler(new RecordClickHandler() { public void onRecordClick(RecordClickEvent event) { form.clearErrors(true); form.editRecord(event.getRecord()); form.enable(); } }); this.setWidth(800); this.addMember(grid); this.addMember(form); } protected void onInit() { } }
Christian
PS: I'm using SmartGWT 4.0.
Comment