Announcement

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

    Changing advenced to simple criteria when changing from advanced to simple filter

    In my application the user has possibility to chose "simple" FilterEditor or "advanced" AdvancedFilter and switch between them.

    The transition from simple to advanced filter works without problems.

    Transition from advanced to simple filter is problematic: it is obvious that simple filter doesn't support all possibilities of advanced filter, so the simple filter doesn't work after the switch.

    I decided to empty the criteria when switching from advanced to simple filter, but this doesn't work either: even when setting an empty criteria by calling ListGrid.setCriteria({}) the criteria type remains AdvancedCriteria, which is not supported by simple filter.

    Workaround for this problem is to explicitely set the ListGrid.data.criteria variable to null or remove it:
    Code:
    delete ListGrid.data.criteria;
    ListGrid.setCriteria();
    but I think that this is not the "official" way since the manual for ResultSet.criteria says: "Use ResultSet.setCriteria() to change the criteria after initialization."

    The proper solution would be:
    - setting empty criteria with setCriteria() should always change the criteria type to simple criteria
    or/and
    - implement a function "unconvertCriteria" (the opposite of convertCriteria), which try to convert advanced criteria back to simple criteria and returns a flag if the conversion was successful or not.

    #2
    There's nothing about setCriteria that should cause criteria to stick - it's probably something in your code causing the issue. If you think it's a bug, please show a minimal stadalone test case reproducing the problem.

    Comment


      #3
      The problem is in file ResultSet.js, method setCriteria :
      Code:
      ...
              if (!ds.isAdvancedCriteria(newCriteria) && ds.isAdvancedCriteria(oldCriteria)) {
                  newCriteria = isc.DataSource.convertCriteria(newCriteria, this._textMatchStyle);
                  this.criteria = newCriteria;
              } 
      ...
      which converts the new criteria type to AdvancedCriteria if the old criteria was AdvancedCriteria type. This makes impossible to change back to simple criteria once the criteria is set to AdvancedCriteria type.

      Please let me know if you still need the test case, since I need some time to prepare it...

      Thanks for quick replay,
      Borut

      Comment


        #4
        It does seem like there's no clear reason to store the converted criteria instead of the original - we'll take a look. In the meantime, your workaround is fine.

        Comment

        Working...
        X