Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1145
Restore Sorting CSS after reloading saved sorting setting
posted

I have successfully reloaded the sorting expressions into a grid from a previous browser session by storing and reloading the sorting.expressions property.

However I notice that the column headers do not display the ascending/descending icon indicators.

In this post Stamen Stychev mentions:

"The downside of this method is that the sort style is not reapplied. Please, let me know if you need to restore the sort style as well because it'll require a different approach."

Could someone explain what is needed so that the sorting indicators are restored too.

Regards

Aidan

Parents
  • 5513
    Offline posted

    Hello Aidan,

    To get the sort style applied you'll have to use the sortColumn method of igGridSorting. The downside of using the sortColumn method is that it works on a single column and will re-render the grid a number of times equal to the amount of sorted columns. Depending on the size of the data source this may cause performance issues.

    Provided you have the sorting expressions array from the data source instance the solution will look similar to the following:

    for (i = 0; i < expressions.length; i++) {
         $("#grid1").igGridSorting("sortColumn", expressions[i].fieldName, expressions[i].dir);
    }

    Placed just under the grid initialization.

    I hope this helps!

    Best regards,

    Stamen Stoychev

Reply Children