viewDefinition and selected Filters?

Posted by: dvomsaal on 6 January 2022, 8:12 am EST

  • Posted 6 January 2022, 8:12 am EST

    It appears that applying a viewDefinition does not reapply the selections in a filtered field. Am I missing something? When I look at the saved viewDefinition the selections are there

    		{
    "binding": "DEPARTMENT",
    "header": "DEPARTMENT",
    "dataType": 1,
    "aggregate": 2,
    "showAs": 0,
    "descending": false,
    "format": "n0",
    "isContentHtml": false,
    "key": "DEPARTMENT",
    "filter": {
    "filterText": "",
    "showValues": {
    "480200: CAMPUS OPERATIONS - DOWELL SPRINGS": true
    }
    }
    },


    but when I reapply the viewDefinition to the engine there is no filter applied.
  • Replied 6 January 2022, 7:28 pm EST

    Hello,

    Sorry but we are unable to replicate the issue at our end, Would you please clarify if you are facing the issue with the shared sample too? If yes, please share some screenshots/gif of the issue or error. If you are facing this issue only in your application but not in the shared sample then it is possible that the issue is arising due to some code specific to your application. Since we are unable to replicate the issue, I would request you to share a sample that demonstrates the issue so that we could further investigate the root cause of the issue and assist you accordingly. Also, if there are certain steps to replicate the issue, then do let us know along with the sample.

    Sample link: https://stackblitz.com/edit/js-ndm48n?file=index.js

    Regards
  • Replied 7 January 2022, 3:18 am EST

    Thank you very much for your response. It enabled me to track down in detail what is going on, and raises another question. It turns out that the Filter is indeed saved, but in a subsequent step I recreate any Slicers that are on the screen, and when I create the Slicer for the filtered field all the filter values are removed. Is there a way to create a Slicer such that any existing filter selections are restored/maintained? Nothing in the Slicer documentation seems to indicate that (a) the filter will be cleared and (b) how to avoid that.

    Thanks!
  • Replied 9 January 2022, 11:45 pm EST

    Hello,

    We apologize but still, we are unable to replicate the issue at our end, could please provide a sample replicating the issue?

    We have prepared a sample for the sam, you can also update the below-shared sample to replicate the issue and send us back so that we can assist you accordingly.

    Sample link: https://stackblitz.com/edit/js-qkzvgs?file=index.js

    Regards
  • Replied 10 January 2022, 8:56 am EST

    Actually, your sample exhibits the same issue.

    1. Load your page
    2. Use the Pivot Panel to pop up the filter settings of Person and change to only have a few selected.
    3. Save the View
    4. Load the View - the Slicer is created, and all the entries under Person are selected rather than just the two you selected in step 2.

  • Replied 10 January 2022, 9:31 am EST

    My code is pretty intertwined, but this is the relevant part:

    debug watch of JSON.parse(panel.viewDefinition).fields[6] shows property "filter" with values set

    This code executes (header = key of field[6]):


    $('#sliceHolder').append('<div id="slicer' + idx + '" class="sliceBox"></div>');
    var s = new wijmo.olap.Slicer('#slicer' + idx, {
    field: engine.fields.getField(header),
    multiSelect: true,
    showCheckboxes: true
    });


    debug watch of JSON.parse(panel.viewDefinition).fields[6] shows no property "filter" any longer.




  • Replied 10 January 2022, 7:03 pm EST

    Hello,

    The is expected behavior as the instance of Slicer gets recreated the checkedItems gets lost. To resolve the issue you may get the underlying instance f ListBox and update the checkedItems as per the saved view definition. Please refer to the same link below demonstrating the same:

    Sample link: https://stackblitz.com/edit/js-tpmjqs?file=index.js

    Regards

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels