Hi,
If FilterBuilder is attached to the DataSource which first visible field is foreign key and its valid operators array is truncated, then an initial operator for such a field is force set to "contains" even though "contains" is not among valid operators.
See this code sample:
The same foreign key field would get the correct initial operator and correct operator list if you just uncomment:
employmentDS.setFields(idField, /*textField,*/ employerField);
to
employmentDS.setFields(idField, textField, employerField);
so it would become the second one after textField.
Thanks,
MichalG
SmartClient Version: v11.1p_2017-09-14/LGPL Development Only (built 2017-09-14)
If FilterBuilder is attached to the DataSource which first visible field is foreign key and its valid operators array is truncated, then an initial operator for such a field is force set to "contains" even though "contains" is not among valid operators.
See this code sample:
Code:
package pl.com.tech4.client; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.DataSourceField; 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.ComboBoxItem; import com.smartgwt.client.widgets.grid.ListGridField; public class MainEntryPoint implements EntryPoint { public void onModuleLoad() { layout(); } private void layout() { DataSource employmentDS = new DataSource(); employmentDS.setID("Employment"); DataSource departmentDS = new DataSource(); departmentDS.setID("Department"); DataSourceField idDepField = new DataSourceField(); idDepField.setName("id"); idDepField.setPrimaryKey(true); idDepField.setHidden(true); DataSourceTextField codeField = new DataSourceTextField(); codeField.setName("code"); departmentDS.setFields(idDepField, codeField); DataSourceField idField = new DataSourceField(); idField.setName("id"); idField.setPrimaryKey(true); idField.setHidden(true); DataSourceTextField textField = new DataSourceTextField(); textField.setName("text"); DataSourceField employerField = new DataSourceField(); OperatorId[] validOperators = new OperatorId[]{ OperatorId.EQUALS, OperatorId.NOT_EQUAL, OperatorId.IS_NULL, OperatorId.NOT_NULL}; employerField.setValidOperators(validOperators); employerField.setName("employer"); employerField.setForeignKey("Department.id"); employerField.setValueXPath("employer/id"); ComboBoxItem defaultItem = new ComboBoxItem("employer"); defaultItem.setOptionDataSource(departmentDS); defaultItem.setValueField("id"); defaultItem.setDisplayField("code"); defaultItem.setPickListFields(new ListGridField("id"), new ListGridField("code")); employerField.setEditorProperties(defaultItem); employmentDS.setFields(idField, /*textField,*/ employerField); FilterBuilder fb = new FilterBuilder(); fb.setDataSource(employmentDS); fb.draw(); } }
The same foreign key field would get the correct initial operator and correct operator list if you just uncomment:
employmentDS.setFields(idField, /*textField,*/ employerField);
to
employmentDS.setFields(idField, textField, employerField);
so it would become the second one after textField.
Thanks,
MichalG
SmartClient Version: v11.1p_2017-09-14/LGPL Development Only (built 2017-09-14)
Comment