如何调用重置选择并在jqGrid中全选? [英] How to invoke the reset selection and select all in jqGrid?
本文介绍了如何调用重置选择并在jqGrid中全选?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在单击外部按钮时重置选定的行并选择所有行?我正在尝试resetSelection()但无法正常工作...
How to reset the selected rows and select all rows on external button click? i am trying to resetSelection() but not working ...
jQuery("selectAll").click(function(){
jQuery('.cbox').trigger('click');
});
jQuery("clear").click(function(){
var grid = $("#list10");
grid.resetSelection();
$('#cb_my_grid').click();
var ids = grid.getDataIDs();
for (var i=0, il=ids.length; i < il; i++ )
grid.setSelection(ids[i], false);
});
推荐答案
The main reason why your code is not work is some syntax errors or wrong usage of jQuery selectors.
您没有发布HTML代码,所以我想它看起来像下面的
You don't post your HTML code, so I suppose it look like following
<input id="selectAll" type="button" value="Select All" />
<input id="clear" type="button" value="Clear Selection" />
<table id="list10"></table>
<div id="pager"></div>
相应的JavaSript代码应如下所示:
The corresponding JavaSript code should be like following:
var grid = $("#list10");
$("#selectAll").click(function(){
grid.jqGrid('resetSelection');
var ids = grid.getDataIDs();
for (var i=0, il=ids.length; i < il; i++) {
grid.jqGrid('setSelection',ids[i], true);
}
});
$("#clear").click(function(){
grid.jqGrid('resetSelection');
});
一个工作示例,您可以在链接下看到.
A working example you can see under the Link .
这篇关于如何调用重置选择并在jqGrid中全选?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文