Wijmo Flexgrid - sort the column headers alphabetically

Posted by: sravya_tamma on 21 April 2020, 1:49 pm EST

  • Posted 21 April 2020, 1:49 pm EST - Updated 3 October 2022, 4:36 pm EST

    Hello,

    After the flex-grid renders, I would like to sort all column headers alphabetically. Below is the order I want to have these headers.

    Taiwan, United Kingdom, United States, WWTotal.

    How can I do this ?

    Thanks,

    Sravya

  • Posted 22 April 2020, 1:39 am EST

    Hi,

    For this, simply call the sort method of the ColumnCollection class and provide a comparator function that will compare the columns according to their headers:

    
    grid.columns.sort(function(a, b) {
      return a.header.localeCompare(b.header)
    });
    

    https://stackblitz.com/edit/js-p7qgm2

    Regards,

    Ashwin

Need extra support?

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

Learn More

Forum Channels