Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQGrid Sorting - how to trigger onSortCol event

Tags:

sorting

jqgrid

I am trying to get the onSortCol event get fired when I press a column header. Currently, when I click a column header, I can see a request going to the server but I want the onSortCol to be fired before this happens. I have pasted below the code I am using.

Am I missing anything? How do i get onSortCol to work?

jQuery("#list").jqGrid('navGrid', "#pager", { edit: false, add: false, del: false },
{onSortCol:function (index, columnIndex, sortOrder)
 {
    alert(index);
    return 'stop';
 }
});
like image 666
jack Avatar asked Sep 21 '10 15:09

jack


1 Answers

You use onSortCol in a wrong way. Currently you use onSortCol as prmEdit (form edit parameters) parameter of navGrid method. Try include onSortCol in the jqGrid definition:

jQuery("#list").jqGrid({
    // other parameters of jqGrid like colModel
    onSortCol: function (index, columnIndex, sortOrder) {
        alert(index);
        return 'stop';
    }
});
like image 50
Oleg Avatar answered Oct 15 '22 03:10

Oleg