javascript Jqgrid多选选定的行数?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7202241/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jqgrid multiselect selected rows count?
提问by dr.linux
I'm using Jqgrid by multiselect option. I want to get selected rows count on Jqgrid .
我正在通过多选选项使用 Jqgrid。我想在 Jqgrid 上获得选定的行数。
I tried that but no luck...
我试过了,但没有运气...
var count = jQuery('#grid').length;
if (count > 5)
alert('The Selected Rows More Than 5')
回答by Oleg
回答by Kai
This works for me: Place a link anywhere you want
这对我有用:在你想要的任何地方放置一个链接
<a href="/" id="displayNoSelectedRows">Click me!</a>
and now simply register the callback function
现在只需注册回调函数
$("#displayNoSelectedRows").click(function() {
var no = $("input[id^='jqg_gridid_']:checked").length;
alert(no);
return false;
});
for this link, where gridid
is the table's id. With the knowledge of how the checkboxes are named (or better the way the ids are assigned) this is a possible way to get the number of selected checkboxes.
对于此链接,gridid
表的 ID在哪里。了解复选框的命名方式(或者更好地分配 id 的方式),这是获取所选复选框数量的可能方法。