Announcement

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

    Programatically restricting FilterBuilder operators

    In one particular scenario I have a situation where I want to further restrict the operators in the FilterBuilder for a particular field under certain conditions. Is there a way I can do this programatically with the FilterBuilder?

    I know the operators can be customized at the DataSource level via validOperators, DataSource.setTypeOperators and I am using both of those in various places as well, but this case is a little different in that depending on programming logic I want to conditionally hide/remove certain operators for a specific field.

    Thanks.

    #2
    There's a method you can override on FilterBuilder and/or FilterClause - getFieldOperators(fieldName).

    The default implementation effectively returns ds.getFieldOperators(fieldName).

    Comment


      #3
      Sounds great but I cannot find any such method on FilterBuilder in the SmartGWT code base I am using:

      SmartClient Version: v9.1p_2014-06-30/Pro Deployment (built 2014-06-30)

      Comment


        #4
        Ah - they're not exposed to SGWT - we'll add them in the next day or so and update here when they're in

        Comment


          #5
          Thank you kindly.

          Comment


            #6
            Ok, we've added these, you can retest with tomorrow's build - only the version on FilterBuilder is presently an override point

            Comment


              #7
              I updated the SmartGWT library from:

              Isomorphic SmartClient/SmartGWT Framework (v9.1p_2014-06-30/Pro Deployment 2014-06-30)

              to

              Isomorphic SmartClient/SmartGWT Framework (v9.1p_2014-07-03/Pro Deployment 2014-07-03)

              and now when I click the + within a FilterBuilder I get the following errors:

              Compiled Mode: "onUncaughtException: undefined"

              Dev Mode: "onUncaughtException: Cannot cast com.google.gwt.core.client.JavaScriptObject$ to java.lang.String"

              If I revert back to the previous build (v9.1p_2014-06-30/Pro Deployment 2014-06-30) the error/exception goes away.

              Comment


                #8
                Yes, sorry about that - due to some internal complications, we've scrapped that new override-point in favour of a new method, FilterBuilder.setFieldOperatorCustomizer(FieldOperatorCustomizer), which receives the default set of OperatorIds for the given field as a parameter.

                You can make use of this as of builds dated July 5.

                Comment


                  #9
                  OK, thanks.

                  Along the same area, is there a way I can set the default operator when a field is picked or added within the FilterBuilder?

                  Comment


                    #10
                    You should be able to install a Changed handler on the "fieldPicker" AutoChild, via setAutoChildProperties(), and have that directly set the value (or defaultValue) of the filterBuilder.operatorPicker.

                    Let us know if that doesn't work for you.

                    Comment

                    Working...
                    X