我有几个包含jqGrid的页面,所有这些页面都定义了默认的onSelectRowEventHandler函数。
在其中一些页面上,我想放入局部视图(@Html.Partial("SpecialGridScripts");
),在文档就绪处理程序中,将第二个事件处理程序绑定到selectrow。当用户选择一行时,原始和自定义事件处理程序都应该触发。
到目前为止我尝试过的(不起作用):
$(document).ready(function () {
jQuery.extend(jQuery.jgrid.defaults, {
onSelectAll: function (ids, selected) {
$(this).triggerHandler("selectAll.jqGrid", [ids, selected]);
},
onSelectRow: function (id, selected) {
$(this).triggerHandler("selectRow.jqGrid", [id, selected]);
},
});
$('#myGrid').bind('selectRow.jqGrid', function (event, id, selected) {
UpdateVisibility();
});
});
答案 0 :(得分:1)
我自己解决了这个问题:
$(document).ready(function () {
jQuery.extend(jQuery.jgrid.defaults, {
onSelectAll: function (ids, selected) {
$(this).triggerHandler("selectAll.jqGrid", [ids, selected]);
},
onSelectRow: function (id, selected) {
$(this).triggerHandler("selectRow.jqGrid", [id, selected]);
},
});
$('#myGrid').on('jqGridSelectRow jqGridSelectAll', function (event, id, selected) {
UpdateVisibility();
});
});
使用jqGrid版本> 4.3.2它使用jQuery事件,所以我可以动态地将它绑定到jqGridSelectRow和jqGridSelectAll。我认为我发布的链接中的解决方案仅适用于jqGrid<版本4.3.2。