Setting the sort order

Posted by: ed on 18 June 2019, 8:54 am EST

    • Post Options:
    • Link

    Posted 18 June 2019, 8:54 am EST

    Working with a MVC Core 2.2 application and Wijmo 5. On loading the grid I want it sorted on a specific column. Tried various ways of using the sortDescription but can’t find anything that works. Here is what I have.

    var summaryGrid = new wijmo.grid.FlexGrid(‘#customerGrid’,

    {

    isReadOnly: true,

    autoGenerateColumns: false,

    itemsSource: customerData,

    columns: [

    { header: ‘id’, binding: ‘id’ },

    { header: ‘Customer Name’, binding: ‘customerName’, width: 250 },

    { header: ‘Current’, binding: ‘currentBalance’, format: ‘c’, width: 100 },

    { header: ‘1 to 30’, binding: ‘pastdue30’, format: ‘c’, width: 100 },

    { header: ‘31 to 60’, binding: ‘pastdue60’, format: ‘c’, width: 100 },

    { header: ‘61 to 90’, binding: ‘pastdue90’, format: ‘c’, width: 100 },

    { header: ‘91 to 120’, binding: ‘pastdue120’, format: ‘c’, width: 100 },

    { header: ‘Over 121’, binding: ‘pastdueOver’, format: ‘c’, width: 100 },

    { header: ‘Balance Due’, binding: ‘customerBalance’, format: ‘c’, width: 100 },

    { header: ‘Ave Days to Pay’, binding: ‘daysToPay’, format: ‘n’, width: 100 }

    ],

    alternatingRowStep: 1

    });
    

    summaryGrid.columns[0].visible = false;

    summaryGrid.headersVisibility = wijmo.grid.HeadersVisibility.Column;

    summaryGrid.sortDescriptions = new wijmo.collections.SortDescription(“customerBalance”, ‘true’);

    Appreciate your help. Ed

  • Posted 18 June 2019, 9:22 pm EST

    Hello,

    Youcan try setting the sortDescriptions property of the collectionView object of FlexGrid instead of setting it on the grid itself. Please refer to the code snippet below:

    summaryGrid.collectionView.sortDescriptions.push(new wijmo.collections.SortDescription("customerBalance", 'true'));
    

    You may also refer to the sample below:

    https://jsfiddle.net/wdnjor8z/

  • Posted 19 June 2019, 2:27 am EST

    Thanks for your help.

Need extra support?

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

Learn More

Forum Channels