Flexgrid - Filter

Posted by: sravya_tamma on 11 August 2020, 2:10 am EST

    • Post Options:
    • Link

    Posted 11 August 2020, 2:10 am EST

    Hi,

    I have a flexgrid which contains ~20,000 rows. Initially the filter was not showing all the values so i bumped up the maxValue count to be “grid.itemsSource.totalItemCount”.

    Issue is : When i filter some items and hit apply it takes more time to filter the grid. Below is the snapshot of my code. I also tested this with small set of data and it works fine. But with larger set it tends to take more time (like 3-4 secs) to filter.

    May i know, if there is any way to improve this filtering efficiency ?

    init(s: wjcGrid.FlexGrid) {
    
    	let count = s.itemsSource.totalItemCount;
    	this.filter.getColumnFilter('vendor_name').valueFilter.maxValues = count;
        	this.filter.getColumnFilter('consolidated_vendor').valueFilter.maxValues = count;
    
    	this.filter.filterApplied.addHandler((s, e) => {
        		let count = s.grid.itemsSource.totalItemCount;
        		this.filter.getColumnFilter('vendor_name').valueFilter.maxValues = count;
        		this.filter.getColumnFilter('consolidated_vendor').valueFilter.maxValues = count;
        		s.grid.select(new wjcGrid.CellRange(0, 0), true);
    
    	});
    }
    

    Thanks,

    Sravya.

  • Posted 12 August 2020, 7:29 am EST

    Hi Sravya,

    If you will set the maxValue to large value like 20000, then the slow performance is an expected behavior because the FlexGridFilter will have to first iterate over each 20000 items to get all the values and using these values, it will have to create a ListBox each time the filter is displayed. And when the filter is applied, then the grid will again iterate over each item to check whether they pass the filter. That is why we set the maxValue to a low value.

    You can use the uniqueValues property of the ValueFilter class to improve the performance:

    https://www.grapecity.com/wijmo/api/classes/wijmo_grid_filter.valuefilter.html#uniquevalues

    Also, you do not need to set the maxValues every time the filter is applied. So, you can remove the filterApplied event handler.

    Regards,

    Ashwin

  • Posted 21 August 2020, 3:41 pm EST

    Thanks Ashwin,

    Yes, I don’t need to set the maxValues inside filterApplied event anymore.

    Thanks,

    Sravya

Need extra support?

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

Learn More

Forum Channels