Wednesday, 4 October 2017

Select Multipal CheckBox or ALL

function GetStudentDetail() {
    var ddlClass = $("#ddlClass");
    var ddlClassId = $("#ddlClass").val();
    $.ajax({
        url: 'WebServices/StudentReportCard.asmx/GetStudentDetails',
        data: { ClassSecId: ddlClassId },
        dataType: "json",
        method: 'post',
        success: OnSuccessStudentDeatil,
        error: function (err) {
            alert('err' + err);
        }
    });
}


function OnSuccessStudentDeatil(data) {
    var row = $("[id*=gvStudentDetail] tr:last-child").clone();
    $("[id*=gvStudentDetail] tr").not($("[id*=gvStudentDetail] tr:first-child")).remove();
    $.each(data, function (index) {
        row.find("td").css("background-color", "#f2f2f2");
        //row.find("td").attr("align", "center");
        var srno = index + 1;
        $("td", row).eq(0).html("<label>" + srno + "</label>" + "<label style=\"display:none\" id=\"lbl_" + index + "\">" + data[index].studentId + "</label>");
        $("td", row).eq(1).html("<label>" + data[index].rollno + "</label>");
        $("td", row).eq(2).html("<label>" + data[index].admno + "</label>");
        $("td", row).eq(3).html("<label>&nbsp;" + data[index].studentName + "</label>");
        $("td", row).eq(4).html("<label>&nbsp;" + data[index].fatherName + "</label>");
        $("td", row).eq(5).html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input id=\"chk_"+index+"\" type=\"checkbox\" onchange=\"return GetSelectedRow(this)\">");
        $("[id*=gvStudentDetail]").append(row);
        row = $("[id*=gvStudentDetail] tr:last-child").clone();
    });
    $("#chkSelectAll").attr("checked",false);
    $("[id*=gvStudentDetail] tr:first-child").find("span").html("SELECT ALL");
    $("#ShowHideStudentDetail").show();
    $("#loadig_Image").hide();
    $("#overlay").hide();
}


//=====
function GetSelectedRow(lnk) {
    var row = lnk.parentNode.parentNode;
    var rowIndex = row.rowIndex - 1;
    //alert(rowIndex);
    var res = row.cells[5].getElementsByTagName("input")[0].checked;
    if (res == true) {
        row.cells[0].style.backgroundColor = "#faf1e1";
        row.cells[1].style.backgroundColor = "#faf1e1";
        row.cells[2].style.backgroundColor = "#faf1e1";
        row.cells[3].style.backgroundColor = "#faf1e1";
        row.cells[4].style.backgroundColor = "#faf1e1";
        row.cells[5].style.backgroundColor = "#faf1e1";
    }
    else {
        //-----------------------
        row.cells[0].style.backgroundColor = "#f2f2f2";
        row.cells[1].style.backgroundColor = "#f2f2f2";
        row.cells[2].style.backgroundColor = "#f2f2f2";
        row.cells[3].style.backgroundColor = "#f2f2f2";
        row.cells[4].style.backgroundColor = "#f2f2f2";
        row.cells[5].style.backgroundColor = "#f2f2f2";
    }

//return true;
    CheckStudentActive();
}
//============

function CheckStudentActive() {
    var Count_True = 0;
    var Count_False = 0;
    var Count_Row = 0;
    $("#gvStudentDetail tr").each(function (index) {
        if (index != "0") {
            var actualindex = index - 1;
            var CheckboxId = "#chk_" + actualindex;
            var aa = $(CheckboxId).is(":checked");
            if (aa == false) {
                Count_False += 1;
            }
            if (aa == true) {
                Count_True += 1;
            }
            Count_Row += 1;
        }

    });
    //alert("true="+ Count_True+" false= "+Count_False);
    if ((parseInt(Count_True) != 0 && parseInt(Count_False) > 0) || (parseInt(Count_False) == parseInt(Count_Row) && parseInt(Count_True) != parseInt(Count_Row))) {
        $("#chkSelectAll").prop('checked',false);
        $("[id*=gvStudentDetail] tr:first-child").find("span").html("SELECT ALL");
    }
    else {
       
        $("#chkSelectAll").prop('checked',true);
        $("[id*=gvStudentDetail] tr:first-child").find("span").html("UNSELECT ALL");
    }
}
//=======Get All CheckedBox  Record=====
var CheckAll = $("#chkSelectAll").is(":checked");
        var StudentId = "0";
        if (CheckAll != false || CheckStudentActive_ForGenerateReport()) {
            //alert("Yes Go");
            if (CheckAll == true) {
                StudentId = "0";
            }
            else {

                $("#gvStudentDetail tr").each(function (index) {
                    if (index != "0") {
                        var actualindex = index - 1;
                        var CheckboxId = "#chk_" + actualindex;
                        var lblstuId = "#lbl_" + actualindex;
                        var aa = $(CheckboxId).is(":checked");
                        if (aa == true) {
                            if (StudentId == "0")
                                StudentId = "'" + $(lblstuId).html() + "'";
                            else {
                                if ($(lblstuId).html() != "") {
                                    StudentId = StudentId + "," + "'" + $(lblstuId).html() + "'";
                                }
                            }
                        }
                    }

                });
            }

No comments:

Post a Comment

IIS deployment support details

  Node JS - IIS deployment support details node: http://go.microsoft.com/?linkid=9784334 IISNode: https://github.com/azure/iisnode/releases/...