Announcement

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

    Filter Builder Simple Mode vs. Advanced Mode

    SmartClient Version: v9.1p_2014-07-06/Pro Deployment (built 2014-07-06)
    FF 24.6.0 ESR

    We display a filter builder in a form with default TopOperatorAppearance.RADIO (Simple Mode), but allow changing to TopOperatorAppearance.BRACKET (Advanced Mode).

    We persist the defined filter.

    If a user changes to Advanced Mode and persists the filter, when opening up the filter form again, how do we detect that we should show the filter in Advanced Mode, rather than the default Simple Mode.

    Do we need to store a flag outside of the filter to specify which mode the filter was defined in?

    Furthermore, is there a way to toggle the TopOperatorAppearance programatically after the filter builder has been created. The setTopOperatorAppearance method says it cannot be called after the filter has been created.

    Thanks

    #2
    If you are using the built-in feature to switch between simple and advanced modes (showModeSwitcher), you should find that the appropriate mode is used automatically so long as you do not try to explicitly specify a topOperatorAppearance.

    However, if you have a JSON object and you are trying to figure out whether it's an AdvancedCriteria, you can just check for a property "_constructor" with value "AdvancedCriteria" at top level.

    Comment


      #3
      Some follow up questions...

      1. FilterBuilder.getCriteria() always returns AdvancedCriteria, so if this AdvancedCriteria is persisted, wouldn't the property "_constructor" always have a value "AdvancedCriteria"?

      2. When showing the FilterBuilder for creating a new filter, we want it to default to "Simple Mode". If we don't specify a topOperatorAppearance, it defaults to "Advanced Mode".

      3. We removed the call to set the topOperatorAppearance and instead used the mode switcher on the UI to switch to "Simple Mode", defined a filter, and persisted it. When loading that criteria back into the filter builder, it always defaults to "Advanced Mode".

      Code:
      AdvancedCriteria criteria = AdvancedCriteria.fromJSON(originalFilterCriteria);
      filterBuilder.setCriteria(criteria);

      Comment


        #4
        1. yes. We assumed you were storing a mixture of criteria, some of which didn't come from a FilterBuilder

        2/3. if you want to ensure that Simple Mode is used whenever possible, you can take your criteria and see if DataSource.canFlattenCriteria() returns true. If so, the criteria can be represented in simple mode without loss of information.

        Comment


          #5
          Thank you.

          The DataSource.canFlattenCriteria() does the trick, however, we still have one remaining issue, specifically, being able to programatically toggle the topOperatorAppearance so we do not need to destroy and recreate the filter builder every time we view a different filter in the form.

          For example, user clicks on record, we load filter into the form and create the filter builder with topOperatorAppearance based on DataSource.canFlattenCriteria(). User clicks another record, we load that record into the same form, and we need to change the topOperatorAppearance based on DataSource.canFlattenCriteria(). Right now, we destroy and recreate the filter builder with the different topOperatorAppearance. Is there a way to do this programatically without destroying and recreating the filter builder? From the user interface a user can click the "Advanced Mode" and "Simple Mode" to toggle between modes. We are looking for an API to do this programatically.

          Thanks

          Comment


            #6
            The issue with FilterBuilder.setTopOperatorAppearance() has been fixed in SGWT 5.0d and 4.1p. Check the next nightly builds.

            Comment


              #7
              Thank you very much.

              Comment


                #8
                Works great. Thank You Kindly.
                Last edited by stonebranch1; 1 Aug 2014, 06:12.

                Comment

                Working...
                X