Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    FilterBuilder first field initial operator not among valid operators

    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:
    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();
        }
    
    }
    Click image for larger version

Name:	defaultFilterOperator3.png
Views:	82
Size:	5.8 KB
ID:	249182
    Click image for larger version

Name:	defaultFilterOperator4.png
Views:	61
Size:	8.0 KB
ID:	249183
    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.

    Click image for larger version

Name:	defaultFilterOperator2.png
Views:	59
Size:	7.6 KB
ID:	249184
    Thanks,
    MichalG

    SmartClient Version: v11.1p_2017-09-14/LGPL Development Only (built 2017-09-14)

    #2
    This has been fixed for builds dated September 18 and later.

    Comment


      #3
      Verified in SmartClient Version: v11.1p_2017-09-19/LGPL Development Only (built 2017-09-19) - fixed.
      Thanks,
      MichalG

      Comment

      Working...
      X