JQGrid排序 - 如何触发onSortCol事件

10
我试图在按下表头时触发 onSortCol 事件。 目前,当我单击列标题时,我可以看到向服务器发送请求,但我希望在此之前触发 onSortCol 。 我已经贴出我正在使用的代码。

我是否遗漏了什么? 如何让 onSortCol 正常工作?

jQuery("#list").jqGrid('navGrid', "#pager", { edit: false, add: false, del: false },
{onSortCol:function (index, columnIndex, sortOrder)
 {
    alert(index);
    return 'stop';
 }
});
1个回答

16
您正在错误地使用 onSortCol。目前,您将 onSortCol 作为 navGrid 方法的 prmEdit(表单编辑参数)参数使用。请尝试在 jqGrid 定义中包括 onSortCol
jQuery("#list").jqGrid({
    // other parameters of jqGrid like colModel
    onSortCol: function (index, columnIndex, sortOrder) {
        alert(index);
        return 'stop';
    }
});

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接