Apply column filter onload

Posted by: parmarkinjalk on 27 January 2020, 5:42 pm EST

    • Post Options:
    • Link

    Posted 27 January 2020, 5:42 pm EST

    Hi Team,

    I am using angular with Wijmo grid and filters. I am calling an API which gives me back the data-set. It has a date column in it. The data we get back is random and I wanted to sort it by latest date 1st without the user having to select that filter. Is there a way to apply filter on-load of data?

    Thanks.

  • Posted 28 January 2020, 1:53 am EST

    Hi Kinjalk,

    You may create an empty CollectionView object with the sortDescriptions property set to ‘Date’, and assign it as the itemsSource of the FlexGrid. And when the data is fetched, assign the data as the sourceCollection of the CollectionView object. Please refer to the sample below for reference:

    https://stackblitz.com/edit/angular-p8s4es

    Regards,

    Ashwin

  • Posted 28 January 2020, 12:33 pm EST

    Thanks Ashwin,

    How do I change it to descending order, to show the latest date first?

  • Posted 28 January 2020, 11:48 pm EST

    Hi,

    Just change the sortDescriptions property to this:

    this.source = new wjcCore.CollectionView([], {
    	sortDescriptions: [{ property: 'date', ascending: false }]
    });
    

    ~regards

Need extra support?

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

Learn More

Forum Channels