jqueryjqgridsortdirection

jqGrid allow only 1 sort direction


jqGrid's sort icon on the column header shows both up and down arrows. Is there a way to force the icon to show only 1 direction like only allowing ascending order?

Thanks.


Solution

  • Check out the jqGrid Event documentation here. You could define your own sorting by returning 'stop' on the onSortCol event. Something like this should work:

    onSortCol: function (index, iCol, sortorder) {
        if (sortorder === "desc") {
                return 'stop';
        } else {
                //do regular sorting.
        }
    }
    

    Also if you do this on gridComplete it should hide the descending arrows:

    gridComplete: function () {
        $('.ui-grid-ico-sort.ui-icon-desc.ui-sort-ltr').hide();
    }