Ability to clear JS based wj-flexgrid column filters

Posted by: dtghuge on 26 November 2021, 4:04 am EST

    • Post Options:
    • Link

    Posted 26 November 2021, 4:04 am EST - Updated 3 October 2022, 12:14 pm EST

    Hi,

    We have JS based custom wijmo grid (wj-flexgrid). we have enabled FlexGridFilter for all the columns of that grid.

    Now, we want to have the ability to clear all applied filters once, instead of checking which filter is applied on which column and clearing those manually.

    To achieve this, we have added one button on the menu, and on click of that button I’m calling one JS function to clear all applied filters.

        
    function clearFilters(){
            //_flexGrid._cv.filters.clear();
            //wijmo.grid.filter = [];
    	_flexGrid.collectionView.filters.clear();
    
            _flexGrid.refresh(); 	//grid object
        }
    
    

    Hare, I tried all available options to clear filters but it won’t clear any filters

    Also, I refreshed the grid object too.

    Could you please help on?

    1. Why filters dose not clear.
    2. Is there any other way to clear multiple filters at once.

    Thanks

  • Posted 29 November 2021, 8:27 am EST

    Hello,

    To clear FlexGridFilter you need to use the clear method of the FlexGridFilter class, instead of clearing the filters array of the collectionView, like:

    
    function clearFilters(){
        flexGridFilter.clear()
    }
    
    

    To clear the FlexGridFilter of a single column you need to get the instance of the columnFilter, to get that you can use the getColumnFilter method of the FlexGridFilter then you can use the clear method of columnFilter to clear the applied filtering of a specific column. Please refer to the link below for reference:

    https://www.grapecity.com/wijmo/api/classes/wijmo_grid_filter.columnfilter.html#clear

    To clear all column filters at once, you may directly use the clear method of the FlexGridFilter. Please refer to the link below for reference:

    https://www.grapecity.com/wijmo/api/classes/wijmo_grid_filter.flexgridfilter.html#clear

    Regards

  • Posted 1 December 2021, 1:45 am EST

    You are right Sonu :slight_smile:

    Created an instance of FlexGridFilter class and called clear method which clears all the filters!

    Thank you

  • Posted 3 December 2021, 7:31 am EST

    Hi Sonu,

    The next challenge is how to retain applied filters after page refresh.

    I have a save button, on click of save values gets saved into DB, and page gets refresh. After refresh, we want to retain all applied filters back on the same grid

    On click of save, I’m storing all applied filters into a local variable so I can reapply those filters after page refresh

    
    var gObj = GridOS.ComponentUtils.getGridObjectById(gridId);
    var filters = gObj.filter; 
    
    

    but didn’t find any option to apply filters back to the grid

    Help Appreciated!

  • Posted 23 December 2021, 12:23 am EST

    Hello,

    The query has already been addressed in a different thread, please refer to this forum thread link for more information: https://www.grapecity.com/forums/wijmo/ability-to-retain-js-based

    Here is a copy of the response:

    You may save the filterDefinition of the FlexGridFilter before refreshing the page and then assign the filterDefinition back to the FlexGridFilter after refreshing the page. You may refer to the following link below for more information:

    Persisting state Demo: https://www.grapecity.com/wijmo/demos/Grid/PersistingState/purejs

    filterDefinition API link: https://www.grapecity.com/wijmo/api/classes/wijmo_grid_filter.flexgridfilter.html#filterdefinition

    Regards

Need extra support?

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

Learn More

Forum Channels