Jqgrid multiselect selected rows count?

倖福魔咒の 提交于 2019-12-22 17:48:09

问题


I'm using Jqgrid by multiselect option. I want to get selected rows count on Jqgrid .

I tried that but no luck...

var count = jQuery('#grid').length;
    if (count > 5)
    alert('The Selected Rows More Than 5')

回答1:


You should just get the length of the array selarrrow:

var selRowIds = jQuery('#grid').jqGrid('getGridParam', 'selarrrow');
alert ('The number of selected rows: ' + selRowIds.length);



回答2:


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.



来源:https://stackoverflow.com/questions/7202241/jqgrid-multiselect-selected-rows-count

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!