Announcement

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

    How to disable automatic appending of criteria when searching through filter editor

    Hi Isomorphic,

    We recently upgraded to 8.1 and facing one major issue in search using filter editor.

    Our default grid has some basic criteria which we were creating as below and passing that in fetchData method.


    var criteria = {
    _constructor:"AdvancedCriteria",
    operator:"and",
    criteria:[
    { fieldName:"state", operator:"inSet", value:["ACTIVE","INACTIVE"]}
    ]}

    Now, we have one more feature that if user open the filter editor we set the default criteria using below api:

    this.grid.setShowFilterEditor(true);
    this.grid.setFilterEditorCriteria (this.grid.getCriteria());

    Now whatever criteria once set using setFilterEditorCriteria can not be cleared and if user change the criteria for the same field it appends the criteria which brings no results:


    New criteria will look like below:

    criteria:[
    { fieldName:"state", operator:"inSet", value:["ACTIVE","INACTIVE"]},
    { fieldName:"state", operator:"inSet", value:["CANCEL"]},

    ]}

    It's not possible for same record to be either ACTIVE/INACTIVE and CANCEL too. If user change the search of the same field then criteria set through setFilterEditorCriteria should not be appended.

    Please let me know if I was not able to explain the issue.

    Thanks,
    Santosh.

    #2
    First thing: if this is a recent upgrade, you should *definitely* move to 8.2, not 8.1. There's no point in further troubleshooting until you do.

    As far as these APIs - setFilterEditerCriteria() wipes the existing criteria and replaces it with whatever you passed. You may be combining criteria inadvertently yourself, or holding onto a copy of criteria that you've already passed to the ListGrid and is being modified by the user's action.

    If you think the framework is actually at fault, work toward isolating the problem to a test case so we can see it happen. But again, don't bother with this until you are on 8.2.

    Comment


      #3
      We can not upgrade at this point as we have already spent testing effort for the upgrade.

      Below is the code for standalone case and we are facing the exact same issue. Please copy provided code in below example:
      http://www.smartclient.com/docs/8.1/a/system/reference/SmartClient_Explorer.html#advancedFilter

      Code:



      isc.ListGrid.create({
      ID: "filterGrid",
      top: 150,
      width:750, height:300, alternateRecordStyles:true,
      dataSource: worldDS,
      autoFetchData: false,
      useAllDataSourceFields: true
      })

      var loadCriteria =
      {
      _constructor:"AdvancedCriteria",
      operator:"or",
      criteria:[
      { fieldName:"continent", operator:"equals", value: "Asia"},
      { fieldName:"continent", operator:"equals", value: "Africa"},
      ]}

      filterGrid.fetchData(loadCriteria );

      isc.IButton.create({
      left: 320,
      title: "Open/Close Filter",
      click: function () {

      if (filterGrid.showFilterEditor){
      filterGrid.setShowFilterEditor(false);
      }else{
      filterGrid.setShowFilterEditor(true);
      filterGrid.setFilterEditorCriteria (filterGrid.getCriteria());
      }
      }
      });



      Steps to reproduce:

      1) Click on try it button after pasting above code:
      2) By default grid will show records for Asia and Africa continent as provided in load criteria.
      3) Now click on Open/Close Filter.
      4) Search for Europe.

      Observed Behavior: No records are found.
      Expected Behavior: Records which have continent as Europe should be displayed.

      Please let us know what can be done to retain the same functionality. We have a button to open and close filter in our production application and customers are used to of this feature.

      Comment


        #4
        Tested the same in 8.2 and it's not working there as well.

        Comment


          #5
          It looks like you're expecting that hiding and re-showing the filterEditor clears the criteria. This is not the case, also, it was not documented to do this, and the current behavior is better. So add code to clear out the criteria if you want it to be cleared.

          Comment

          Working...
          X