jqgrid选择复选框 [英] jqgrid select checkbox
问题描述
通过使用以下代码,我在网格上有了一个复选框:
I have a checkboxes on my grid by ways of having the following code:
colNames: [..., 'Select'],
...
...
{ name: 'act', index: 'act', width: 30, sortable: false }
....
<input type="button" id="bUpload" value="Upload Report" />
用户在上传"按钮上单击的内容,并且用户为此列选择了多个复选框,我想显示一条消息.我不确定该怎么做.
What the user clicks on the Upload button, and the user has multiple checkboxes selected for this column, I like to show a message. I am not sure how to do this.
我尝试了以下方法,但
$("#bUpload").click(function() {
var selectedRow;
if ($("input:checked").length > 1)
{
alert('Error - Please select only one row.');
return false;
}
if ($("input:checked").length > 0)
{
$("input:checked").each(function()
{
selectedRow = this.value ;
});
}
....
这行得通,但是我不喜欢它的原因是因为我可以为其他列设置其他复选框,以及是否可能从行为"列中选择它们时会感到困惑.我怎么说,如果该列是行动",那么请检查选择了多少个.
This works but the reason why I do not like this is because I can have other checkboxes for other columns as well to where there can be confusion as to if they selected from the 'act' column or not. How do I say if the column is for 'act' then check how many were selected.
推荐答案
您可以遍历网格中的每一行并测试每一行.
You could iterate through each row on the grid and test each row.
//iterate over each row
var rowIds = $('#gridName').jqGrid('getDataIDs');
for (i = 1; i <= rowIds.length; i++) {
rowData = $('#gridName').jqGrid('getRowData', i);
if(rowData['act'] //etc..checkbox check) {
}//if
}//for
这篇关于jqgrid选择复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!