I'm currently counting all the checked checkboxes in an asp.net gridview using:
我目前正在计算asp.net gridview中使用的所有复选框:
$('#cphMain_gdvSalesOrder').delegate('input:checkbox', 'click', function() {
var count = $('#cphMain_gdvSalesOrder').find('input:checkbox:checked').length;
Whereas I need to count all the checkboxes that are checked apart from the one in the header.
然而,我需要数除标题中的所有复选框之外的所有复选框。
Any ideas would be great, thanks
任何想法都很好,谢谢。
Korv
Korv
2 个解决方案
#1
3
You can assign a "flag" CSS Class to the check-boxes in the grid which is not assigned to the check-box in the header. This way you can filter out the header check-box as part of your selector based on CSS Class.
您可以将“标志”CSS类分配给网格中的复选框,该复选框没有分配给标题中的复选框。这样,您就可以根据CSS类过滤掉标题复选框,作为选择器的一部分。
:not(.headerCheckBox)
:没有(.headerCheckBox)
#2
0
var count = 0;
var grid = document.getElementById("<%=grdProductImage.ClientID%>");
var chk = grid.getElementsByTagName("input");
for (var i = 0; i < chk.length; i++)
{
if (chk[i].checked && chk[i].id.indexOf("chkAll") == -1) {
count = count + 1;
}
}
#1
3
You can assign a "flag" CSS Class to the check-boxes in the grid which is not assigned to the check-box in the header. This way you can filter out the header check-box as part of your selector based on CSS Class.
您可以将“标志”CSS类分配给网格中的复选框,该复选框没有分配给标题中的复选框。这样,您就可以根据CSS类过滤掉标题复选框,作为选择器的一部分。
:not(.headerCheckBox)
:没有(.headerCheckBox)
#2
0
var count = 0;
var grid = document.getElementById("<%=grdProductImage.ClientID%>");
var chk = grid.getElementsByTagName("input");
for (var i = 0; i < chk.length; i++)
{
if (chk[i].checked && chk[i].id.indexOf("chkAll") == -1) {
count = count + 1;
}
}