Javascript 使用GLYPH图标作为复选框(图标检查和图标检查为空),如何获取总检查行数
基于这样一个事实,我正在为行中的第一列使用图标集,默认设置为icon check empty,如下所示:Javascript 使用GLYPH图标作为复选框(图标检查和图标检查为空),如何获取总检查行数,javascript,jquery,datatables,Javascript,Jquery,Datatables,基于这样一个事实,我正在为行中的第一列使用图标集,默认设置为icon check empty,如下所示: <i id="dataCbx{{id}}" style="text-align:center;" class="icon-check-empty center pointerCursor" title="Click here to check/uncheck the box. This will indicate you want to CLEAR this alert from
<i id="dataCbx{{id}}" style="text-align:center;" class="icon-check-empty center pointerCursor"
title="Click here to check/uncheck the box.
This will indicate you want to CLEAR this alert from the list.
Click on another part of the row to expand collapse without affecting
the checkbox" onclick="changeIcon(this.id); checkAlerts(this.id);">
</i>
所以用户只检查一行,我对此很满意。。。但是当/如果用户随机选择多行时,我将如何捕获它
因此,基本上,我将使用PUT通过web服务发送ID,并将确认标志更改为TRUE或FALSE
下面是当用户选中单个框COL 0时工作的代码余额。此复选框不是输入字段。。。而是一个字形图标
function sortFilterClear(what) {
var listOfIDs = new Array();
if (what === "sort")
{
//Sorting on attribute
$('#alertTable > tr > td').tsort({attr: 'data-alert-level'});
} else {
//First check to see if the "SELECT ALL" CBX is checked...
if ($("#cbxMaster").hasClass("icon-check"))
{
bootbox.confirm("You are about to clear all alerts\n\n\
Are you sure this is what you want to do?\n\n\
Click OK to Clear or CANCEL to do nothing.", function(result) {
//This is for the RESULT tab to pop out from the RIGHT OPTIONAL
//Example.show("Confirm result: " + result);
if(result)
{
//Send to command - CLEAR EVERYTHING!!!!!!!!!!!!
_clearCheckedRows(myAlertURL,'all');
}
});
} else if (currID.length > 0){
bootbox.confirm("You are about to clear a single alert with ID number: " + currID
+ "<br>Are you sure this is what you want to do?<br>"
+ "Click OK to Clear or CANCEL to do nothing.", function(result) {
//This is for the RESULT tab to pop out from the RIGHT OPTIONAL
//Example.show("Confirm result: " + result);
//NOW check if the user has said CANCEL!!!!!!!!
if(!result)
{
//IF SO, then CLEAR that SPECIFIC CHECKBOX and then STOP
changeIcon(currID);
//CLEAR CURRENT ID
currID="";
} else {
//HERE's where we actual DUMP the a single row.
_clearCheckedRows(myAlertURL,currID);
//HERE's where I'll check for MULTIPLE ROWS SELECTED
// SOME CODE GOES HERE
}
});
}
}
}
谢谢
Peter您可以获得图标复选元素列表,这就是您的复选框:
var listOfIds = [];
$('.icon-check').each(function() {
listOfIds[listOfIds.length] = $(this).id;
});
alert(listOfIds);
但是,通过JavaScript将普通复选框与隐藏类和设置状态一起使用是一种很好的做法,为什么不使用真正的复选框和标签呢?您始终可以将其隐藏并将图标放在标签中。而不仅仅是普通的旧形式。我很乐意。。。但是项目经理想要一个字形图标没有复选框…我同意,因为我有一个功能,我用它来选中/取消选中字形。我没有说摆脱它们!再读一遍我说的。哦!又一个荷马·辛普森的时刻。。。很抱歉是的,我试试看。谢谢。我试试这个。。。但是我们今天要做一个演示,COB,我没有时间改变这一点。。。下周我可以…我们做到了!!!!!!谢谢你,宝贝。上周五一直工作到午夜。。。谢谢你的帮助