모든 행에 대해 확인란이 추가 된 표가 있습니다. 확인란을 클릭하지 않고 삭제 버튼을 클릭하면 "수행 할 행을 하나 이상 선택하십시오"라고 표시됩니다. 확인란을 클릭하면 같은 메시지가 표시됩니다. 아래의 언급 된 코드에서 해본 해결책과 실수를 찾도록 도와주세요.삭제 기능 jquery에서 id를 전달하는 확인란을 클릭하십시오.
//Calling Delete function clicking on checkbox
$(document).ready(function() {
//Grid Function
$.ajax(
{
url: "GetCompanyTypeMasterDetails",
type: "get",
dataType: "json",
contentType: "application/json",
success: function (data) {
$("#grid").igGrid({
autoGenerateColumns: false,
primaryKey: "CompanyTypeID",
columns: [
{ headerText: "Company Type ID", key: "CompanyTypeID", dataType: "Numeric", hidden: true },
{
headerText: "", key: "CompanyTypeID", dataType: "Numeric", width: "80",
template: '<table><tr><td><input type="image" src="/Images/GridImages/edit.png" onclick = "EditRecords(${CompanyTypeID})" /></td><td><input type="image" src="/Images/GridImages/delete.png" onclick = "DeleteRecords(${CompanyTypeID})" /></td></tr></table>'
},
{ headerText: "", key:"CompanyTypeID", dataType:"Numeric", width:"50", template: '<input type="checkbox" id="chkID" />'},
{ headerText: "Company Type", key: "CompanyTypeName", dataType: "string", width: "600" },
{ headerText: "Company Code", key: "Code", dataType: "string", width: "600" },
dataSource: data}
});
$("#btnDelete").click(function (ID) {
var isSelected = $('#chkID').is(':checked');
if (!isSelected) {
alert("Please select atleast one row to perform this action");
}
else if (isSelected) {
DeleteRecords(ID);
}
});
});
});
//Delete Function
function DeleteRecords(ID) {
$.ajax(
{
url: "DeleteRecords",
type: "post",
dataType: "json",
data: {CompanyTypeID : ID},
success: function (data) {
alert("Are you sure you want to Delete?");
location.reload();
},
error: function (status) {
alert(status.responseText);
}
});
}
을하고있다 여기에
을, 다른 ID를 사용하거나 클래스를 사용하십시오. –
어떻게 그리드에 행을 추가하는지 보여주세요. –
정확히 어떤 문제에 대한 해결책을 원하십니까? – Leo