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
65
Currently-sorted column and sorting direction?
posted

Is there a way to determine which column the grid is currently sorted on and the direction in which it is sorted? (Aside from using the columnSorting event, which only fires when the user changes the sort?)

Parents
  • 24671
    Verified Answer
    posted

    Hi,

    sure. you can get the column settings which correspond to the columnKey, where columnSettings[x].columnKey = <key of the column you want to check>, then the property currentSortDirection will tell you if it's sorted or not ("asc" or "desc"). 

    var sorting = $("#gridID").data("igGridSorting");

    var settings = sorting.columnSettings;

    for (i = 0; i < settings.length; i++) {

    if (settings[i].currentSortDirection === "asc" || settings[i].currentSortDirection === "desc") {

    // it's sorted. 

    }

    }

    Hope it helps. Thanks,

    Angel

Reply Children
No Data