Using a FieldOperatorCustomizer with FilterBuilder, not all the specified operators are displayed.
As per the following example, if "Boolean Field" is selected, you should see four operators in the list (equals, not equal, null, is not null).
Actually, this is the case if the code is compiled for example with SmartGWT LGPL version 6.0-p20161211.
However, using a more recent LGPL version, for example 6.1-p20170808, only two operators are displayed in the list (eqals, not equals).
The only difference between the cases is SmartGWT version.
As per the following example, if "Boolean Field" is selected, you should see four operators in the list (equals, not equal, null, is not null).
Actually, this is the case if the code is compiled for example with SmartGWT LGPL version 6.0-p20161211.
However, using a more recent LGPL version, for example 6.1-p20170808, only two operators are displayed in the list (eqals, not equals).
The only difference between the cases is SmartGWT version.
- your GWT version & Smart GWT version: 2.8.0 & 6.0-p20161211 and 6.1-p20170808 respectively
- whether you were in Super Dev Mode, Classic/Legacy Dev Mode, or compiled mode: super dev mode
- browser version and operating system: independent, tried with recent versions of Chrome and Firefox
- what you expected to happen, and, if applicable, the Smart GWT documentation that led you to believe your approach would work: please see the description above
Code:
import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.fields.DataSourceBooleanField; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.types.OperatorId; import com.smartgwt.client.widgets.form.FilterBuilder; import com.smartgwt.client.widgets.form.fields.FieldOperatorCustomizer; public class dummyModule implements EntryPoint { public void onModuleLoad() { FilterBuilder filterBuilder = new FilterBuilder(); filterBuilder.setDataSource(new FilterDS()); filterBuilder.setFieldOperatorCustomizer(new FieldOperatorCustomizer() { @Override public OperatorId[] getFieldOperators(String fieldName, OperatorId[] defaultOperators, FilterBuilder filterBuilder) { return "booleanField".equals(fieldName) ? new OperatorId[] {OperatorId.EQUALS, OperatorId.NOT_EQUAL,OperatorId.IS_NULL, OperatorId.NOT_NULL} : defaultOperators; } }); filterBuilder.draw(); } } class FilterDS extends DataSource { public FilterDS() { DataSourceTextField textField = new DataSourceTextField("textField", "Text Field"); DataSourceBooleanField booleanField = new DataSourceBooleanField("booleanField", "Boolean Field"); setFields(textField, booleanField); setClientOnly(true); } }
Comment