I have used select2 ajax in datatable Jquery back end data of datatable is asp.net.
Everything work well, i can type to search via Ajax but after i click button to iterate datatable and send data to server to process i can’t type select2 in search field.
This problem occur in Google chrome which i try to use Firefox don’t found any problem
initialize Select2 in drawCallback
$('.ddlHospCodeSelect').select2({
ajax: {
url: '<%=ResolveUrl("~/WS_WebService1.asmx/Get_RequesterDetail") %>',
//url: 'WS_WebService1.asmx/Get_RequesterDetail',
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
delay: 250,
data: function (params) {
var search = '';
if (params.term !== undefined) {
search = params.term;
}
return "{'q': '" + search + "'}";
},
processResults: function (data) {
return {
results: $.map(JSON.parse(data.d), function (obj) {
// console.log(obj);
return { id: obj.Hospital_Code, text: obj.Hospital_Name };
})
};
}
},
placeholder: 'Search here',
minimumInputLength: 1,
//}).prop('required', true).trigger('change');
});
this is iterate value function
*function GetValue() {
let tbl = $("#<%=GrdNewSSO.ClientID%>").DataTable();
let isValidRequireField = 'Valid';
let EmpJsonobj = [];
tbl.rows().every(function () {
let row = $(this.node());
let col0 = row.find('td:first-child input[type="checkbox"]');
if (col0.is(':checked')) {
let item = {};
item.EmployeeID = row.find('td').eq(1).html();
item.HospCode1 = row.find("[id*=ddlHospCode1]").val();
item.HospCode2 = row.find("[id*=ddlHospCode2]").val();
item.HospCode3 = row.find("[id*=ddlHospCode3]").val();
item.StatusChild = row.find("[id*=ddlStatusChild]").val();
item.ChildCount = row.find("[id*=Childquantity]").val();
item.ChildCount = (item.ChildCount == '') ? 0 : item.ChildCount;
let One = row.find("[id*=DateChild]").val();
let Two = row.find("[id*=DateChild_2]").val();
item.Childoneyear = (One == '') ? '1900-01-01' : One;
item.Childtwoyear = (Two == '') ? '1900-01-01' : Two;
if (item.HospCode1 === null) {
alert('You have to choose Hospital at ' + item.EmployeeID);
isValidRequireField = 'Invalid';
}
if (item.StatusChild === 'Y') {
if (item.ChildCount === 0) {
alert('You have to fill Child count at ' + item.EmployeeID);
isValidRequireField = 'Invalid';
}
}
item.UpdateByUser = '<%=Session["Emp_ID"] %>';
EmpJsonobj.push(item);
}
});
return (isValidRequireField === 'Invalid')? isValidRequireField:EmpJsonobj;
}*