Announcement

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

    FilterBuilder bug: operations missing in recent SmartGWT versions

    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.
    • 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);          
        }
    }

    #2
    Please test with the latest build from smartclient.com/builds - you should always do this before reporting a bug but, in this case, some specific fixes have been made in this area since your build from August.

    Comment


      #3
      I have got the same result with the latest version v11.1p_2017-12-16/LGPL Development Only (built 2017-12-16)

      Comment


        #4
        Hi, I have the same problem. (SGWT Pro 6.1 released December 16, 2017)
        Using a FieldOperatorCustomizer with FilterBuilder, not all the specified operators are displayed.

        Code:
        ......
        filterBuilder.setFieldOperatorCustomizer(new FieldOperatorCustomizer() {
                    @Override
                    public OperatorId[] getFieldOperators(String fieldName, OperatorId[] defaultOperators, FilterBuilder filterBuilder) {
                        if ("dateTimeField".equals(fieldName)) {
                            return new OperatorId[] { OperatorId.EQUALS, OperatorId.NOT_EQUAL, OperatorId.LESS_THAN, OperatorId.GREATER_THAN, OperatorId.LESS_OR_EQUAL, OperatorId.GREATER_OR_EQUAL, OperatorId.NOT_NULL, OperatorId.IS_NULL };
                        } else if ("booleanField".equals(fieldName)) {
                            return new OperatorId[] { OperatorId.EQUALS, OperatorId.NOT_EQUAL, OperatorId.IS_NULL, OperatorId.NOT_NULL };
                        }
        
                        return new OperatorId[] { OperatorId.ICONTAINS, OperatorId.ISTARTS_WITH, OperatorId.IENDS_WITH, OperatorId.IEQUALS, OperatorId.INOT_EQUAL, OperatorId.INOT_CONTAINS, OperatorId.INOT_STARTS_WITH, OperatorId.INOT_ENDS_WITH, OperatorId.EQUALS, OperatorId.NOT_EQUAL, OperatorId.LESS_THAN,
                                OperatorId.GREATER_THAN, OperatorId.LESS_OR_EQUAL, OperatorId.GREATER_OR_EQUAL, OperatorId.NOT_NULL, OperatorId.IS_NULL };
                    }
                });
        Thanks

        Comment


          #5
          isNull and notNull are internally flagged as hidden - we'll look at the logic in that area but, in the meantime, you can use isBlank and notBlank instead and that should give you the results you expect.

          Comment


            #6
            As we noted, some search operators are marked internally as being hidden, including "isNull" and "notNull" - "isBlank" and "notBlank" are functionally equivalent and considered generally more easily understood by users in most environments.

            However, if you want to include "isNull" and "notNull", you just need to flag them as valid by calling field.setValidOperators() in your DataSource - then they'll appear as expected in FilterBuilders and elsewhere.

            Comment


              #7
              Thanks a lot!

              Comment


                #8
                +1 thanks

                Comment

                Working...
                X