Hi,
We are using customized FilterBuilder to build criterias. There seems to be an issue when configuring the FilterBuilder to use a data source for fields and at the same time, overriding setFieldOperatorCustomizer to provide operators for these fields. The select item used to choose the operator gets stuck with incorrect operators when changing the field in the criteria.
We've debugged this a bit and it seems that the problem might lie in the logic how SelectItem's "updateValueMap" function determines values as valid or not: When the optionDataSource for the item is set, it accepts all values as valid and this results in wrong operators in the item.
Reproducible with the following code. Run the code, change the field from "field a" to "field b" and vice-versa and observe that the operator selector gets invalid values stuck from time to time.
Using SmartGWT 6.1p (v11.1p_2018-04-23/LGPL Development Only (built 2018-04-23))
We are using customized FilterBuilder to build criterias. There seems to be an issue when configuring the FilterBuilder to use a data source for fields and at the same time, overriding setFieldOperatorCustomizer to provide operators for these fields. The select item used to choose the operator gets stuck with incorrect operators when changing the field in the criteria.
We've debugged this a bit and it seems that the problem might lie in the logic how SelectItem's "updateValueMap" function determines values as valid or not: When the optionDataSource for the item is set, it accepts all values as valid and this results in wrong operators in the item.
Reproducible with the following code. Run the code, change the field from "field a" to "field b" and vice-versa and observe that the operator selector gets invalid values stuck from time to time.
Code:
viewport = new VLayout(); viewport.setWidth100(); viewport.setHeight100(); FilterBuilder fb = new FilterBuilder(); fb.setRetainValuesAcrossFields(false); DataSource fds = new DataSource(); Record a = new Record(); a.setAttribute("name", "a"); a.setAttribute("title", "field a"); a.setAttribute("type", "text"); Record b = new Record(); b.setAttribute("name", "b"); b.setAttribute("title", "field b"); b.setAttribute("type", "text"); fds.setTestData(a, b); fds.setClientOnly(true); fb.setFieldDataSource(fds); fb.setFieldOperatorCustomizer(new FieldOperatorCustomizer() { @Override public OperatorId[] getFieldOperators(String fieldName, OperatorId[] defaultOperators, FilterBuilder filterBuilder) { if("a".equals(fieldName)) { return new OperatorId[] { OperatorId.EQUALS, OperatorId.NOT_EQUAL }; } else if("b".equals(fieldName)) { return new OperatorId[] { OperatorId.IN_SET, OperatorId.NOT_IN_SET }; } return defaultOperators; } }); viewport.addMember(fb); viewport.draw();
Comment