使用GLYPH图标作为复选框(图标检查和图标检查为空),如何获得检查的行总数

Using GLYPH Icons as check boxes (icon-check and icon-check-empty), how to get total checked rows

本文关键字:图标 检查 何获得 复选框 GLYPH 检查和 使用      更新时间:2023-09-26

基于我为行中的第一列使用图标集的事实,默认值是(图标检查为空),如下所示:

<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>

所以用户检查一个ROW,我对此很满意。。。但是,当/如果用户随机选择多行时,我将如何捕捉?

因此,基本上,我将使用PUT通过web服务发送ID,并将已确认的标志更改为TRUE或FALSE。

以下是当用户选中SINGLE框(COL0)时工作的代码的平衡。此复选框不是INPUT字段。。。而是GLYPH标志。

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 设置状态是一种很好的做法