ahmed salah

ahmed salah

  • 1.1k
  • 654
  • 41.6k

How to remove row on client side by jQuery based on key auditor id and

May 21 2024 11:42 PM

I work on jQuery with asp.net . I face issue I can't remove row from grid view based on key AUD_RECID and P_BUDGET_YEAR .

AUD_RECID with different P_BUDGET_YEAR so I need key will be both from AUD_RECID and P_BUDGET_YEAR

SO I will have unique Value when remove row and it will remove it success based on key contain both (AUD_RECID,P_BUDGET_YEAR)

I can't add P_BUDGET_YEAR with AUD_RECID to be one key for remove this is my issue .

code below working when remove based on AUD_RECID so

my modification need add P_BUDGET_YEAR with AUD_RECID to be as key when delete

what I try as below

1- When press delete row on every row on grid view .

function ADD_AUDITORWithComplain() {
    var AUD_RECID = $("#ddlP_AUDITORS_CURInfo").val();
    var AUD_DESC = $("#ddlP_AUDITORS_CURInfo option:selected").text();
    var P_BUDGET_YEAR = $("#ddlP_BUDGET_YEAR_CUR option:selected").text();
    
    
    $.ajax({
   
        data: "{'AUD_RECID':'" + AUD_RECID +
            "','AUD_DESC':'" + AUD_DESC +
            "','P_BUDGET_YEAR':'" + P_BUDGET_YEAR +
            "'}",
        dataType: "json",
       
        success: function (Result) {
            CloseLoading();

            $.each(Result.d, function (key, value) {

                if (value.Status == "1") {

                    if (value.ADDED_AUDITORS_INFO != null) {
                        if (value.ADDED_AUDITORS_INFO.length > 0) {
                            $("#gvP_AUDITORS").empty();
                            var rowNo = 1;
                            for (var i in value.ADDED_AUDITORS_INFO) {

                                if (rowNo == 1) {
                                    $("#gvP_AUDITORS").append("<tr class='card-info card-header text-white text-center'><th>?</th><th>????? ????????</th><th>????? ???????</th><th></th></tr>");

                                }
                                var row = "<tr align='center' id='tr" + value.ADDED_AUDITORS_INFO[i].AUD_RECID + "' class='record clickable-row'> " + "<td class='tdCount'>" +
                            
                                    (rowNo) + "</td><td>" +
                                    value.ADDED_AUDITORS_INFO[i].AUD_DESC + "</td> <td>" + value.ADDED_AUDITORS_INFO[i].P_BUDGET_YEAR + "</td> <td>" +

                                    " <a '#' id='" + value.ADDED_AUDITORS_INFO[i].AUD_RECID + "' class='delbutton btn btn-outline-danger' onClick='DELETE_AUDITOR_CONFIRM_COMPLAIN(\"" + value.ADDED_AUDITORS_INFO[i].AUD_RECID +
                                    "\",\"" + value.ADDED_AUDITORS_INFO[i].P_BUDGET_YEAR +
                                    "\",\"" + "?? ??? ????? ?" +
                                    "\",\"" + "???? ??? ??????? : " + value.ADDED_AUDITORS_INFO[i].AUD_DESC +
                                    ", ?? ???? ???????? ?" + "\");return false;' data-toggle='tooltip' title='" + value.ADDED_AUDITORS_INFO[i].AUD_DESC + " '> ???</a>" +

                                    " </td></tr>";


                                row = $(row).hide();
                                $('#gvP_AUDITORS').append($(row));
                                rowNo++;


                                $(row).fadeIn(1000);

                            }
                        }
                    }
   

                    $("#ddlP_AUDITORS_CURInfo").val('').trigger("chosen:updated");
                    ModelSuccessDanger('????? ?????', value.StatusDesc, '1', null);

                }
                else {


                    ModelSuccessDanger('???? !!', value.StatusDesc, '0', null);
                }
            });
        }
       
    });
}

 

2- when click yes or no for confirm dialog

function DELETE_AUDITOR_CONFIRM_COMPLAIN(AUD_RECID, P_BUDGET_YEAR,
    title, message) {

    if (custom_confirm(title, message, (ans) => {
        if (ans) {
            DELETE_AUDITOR_COMPLAIN(AUD_RECID, P_BUDGET_YEAR);
            return true;
        } else {

            return false;
        }
    }) == true) {

        return true;
    }
    else {
        return false;
    }

}

 

3- WHEN change id for delete I need to be based on AUD_RECID and P_BUDGET_YEAR

function DELETE_AUDITOR_COMPLAIN(AUD_RECID, P_BUDGET_YEAR) {


    $.ajax({
     
        contentType: "application/json; charset=utf-8",

        data: "{'AUD_RECID':'" + AUD_RECID +
            "','P_BUDGET_YEAR':'" + P_BUDGET_YEAR +
            "'}",
        dataType: "json",
       
        success: function (Result) {
            CloseLoading();

            $.each(Result.d, function (key, value) {

                if (value.Status == "1") {
                    if (AUD_RECID == "") {
                        $("#gvP_AUDITORS").empty();
                    }
                    else {

      

                        var btnDeleteID = AUD_RECID;
                        var record_id = $('#' + btnDeleteID).attr("id");


                     
                        var tr_id = $('#' + btnDeleteID).parents(".record");


    
                        tr_id.css("background-color", "#F2DEDE");

                     
                        tr_id.fadeOut(500, function () {

                            //Remove GridView row
                            tr_id.remove();
                            totalRows = $("#gvP_AUDITORS tr").length;
                            if (totalRows < 2) {
                                $("#gvP_AUDITORS").empty();
                            }
                            var i = 1;
                            $('#gvP_AUDITORS > tr > .tdCount').each(function () {
                                $(this).text(i);
                                i++;
                            });
                        });
                    }

                    //ModelSuccessDanger('????? ?????', value.StatusDesc, '1', null);

                }
                else {


                    ModelSuccessDanger('???? !!', value.StatusDesc, '0', null);
                }
            });
        }
    });
}

 


Answers (1)