最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - JqGrid check to see if the row is selected - Stack Overflow

programmeradmin1浏览0评论

Hi im trying to check to see if a row is selected in jqGrid and if it is then toggle the selection.

I know i can deselect the current row using

`.jqGrid('setSelection', rowid, false);`

and

.jqGrid('resetSelection'); 

applys this to every row in the grid. But i need to check if the row is already selected before i deselect it.

But what i need to do is an if statement that checks if the selected row is selected and if so do some code but i don't know how to get the true or false value from the row. I've tried using and alert to see what the setSelection reruns but it just displays [object object]. Thank you for any help.

Hi im trying to check to see if a row is selected in jqGrid and if it is then toggle the selection.

I know i can deselect the current row using

`.jqGrid('setSelection', rowid, false);`

and

.jqGrid('resetSelection'); 

applys this to every row in the grid. But i need to check if the row is already selected before i deselect it.

But what i need to do is an if statement that checks if the selected row is selected and if so do some code but i don't know how to get the true or false value from the row. I've tried using and alert to see what the setSelection reruns but it just displays [object object]. Thank you for any help.

Share Improve this question asked Nov 26, 2014 at 15:06 Tony_89Tony_89 8171 gold badge15 silver badges40 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

You can use .jqGrid("getGridParam", "selrow") and .jqGrid("getGridParam", "selarrrow") (be carefull in the strange name of the option) to get internal options which hold the last selected rowid and the array of rowids of selected rows. So, if you need to check whether the row with the rowId is selected and you use multiselect: true option, then you can use the following code template

var selRowIds = $("#grid").jqGrid("getGridParam", "selarrrow");
if ($.inArray(rowId, selRowIds) >= 0) {
    // the row having rowId is selected
}
发布评论

评论列表(0)

  1. 暂无评论