I'm trying to use jQuery Datatables(multiple datatables) that connects to WCF Rest Service to get data.Using stored procedures I am binding values.
My code as follows:
//SectionII DataTable
function DataTable_Report() {
CommonValue();
$.ajax({
url: "../Handler.ashx",
type: "POST",
datatype: 'json',
cache: false,
data: { "fromDate": fromDate, "toDate": toDate, "OfficerId": OfficerId, "stateShortName": stateShortName, "request": "SectionIIGetRequest" },
beforeSend: function () {
$(".SectionII-datatables").html("<img src='../images/ajax-loader.gif' alt='Loading...' style='width:220px;height:19px;margin:35px auto 0 auto;display:block' class='dataTable_loader'/>");
},
success: function (data) {
var dt = $.parseJSON(data);
if (dt.Values == null)
$(".SectionII-datatables").html("<h1 style='color:red;text-align:center;margin:2% auto;' class='dataTable_loader'>No Records to display</h1>");
if (dt.ResponseCode == "1001") {
$(".SectionII-datatables dataTable_loader").remove();
$('.SectionII-datatables').html('<table width="100%" cellpadding="0" cellspacing="0" border="0" class="ReportHeader" id="SectionII-table"></table>');
$('#table_id').dataTable();
Values = dt.Values;
table = $('table#table13').dataTable({
"bJQueryUI": false,
"sPaginationType": "full_numbers",
"bAutoWidth": false,
"bPaginate": false,
"bFilter": false,
"bInfo": false,
"bSearch": false,
"aaSorting": [],
"aaData": Values,
"aoColumns": [
{ "sTitle": "", "mData": "Code", "mRender": fnDefaultValue },
{ "sTitle": "", "mData": "Channel", "mRender": fnDefaultValue },
{ "sTitle": "", "mData": "_Amount", "mRender": fnDefaultValue },
{ "sTitle": "", "mData": "Nos", "mRender": fnDefaultValue }
]
});
}
else if (dt.ResponseCode == "2001") { Values = ""; }
}
});
var fnDefaultValue = function (value) { return value; }
}
and my service code as follows:
public WebResponseForSelect<ReportEntity> sectionII(string fromDate, string toDate, int officerid, string stateshortname)
{
Parameters();
prm[0].Value = fromDate;
prm[1].Value = toDate;
if (officerid.Equals(0))
prm[2].Value = null;
else
prm[2].Value = officerid;
if (stateshortname.Equals(string.Empty))
prm[3].Value = null;
else
prm[3].Value = stateshortname;
dt = dbcon.ExecuteSP("getNMLSsectionII", prm);
List<NMLSReportEntity> listSectionII = (from e in dt.AsEnumerable()
select new NMLSReportEntity
{
NMLSCode = e.Field<string>("NMLSCode"),
Channel = e.Field<string>("Channel"),
_Amount = e.Field<string>("totalAmt"),
No_Of_ = e.Field<string>("Nos")
}).ToList<NMLSReportEntity>();
if (listSectionII.Count > 0)
return new WebResponseForSelect<NMLSReportEntity>() { ResponseCode = "1001", ResponseMessage = "Successfully retrieved", Values = listSectionII };
else
return new WebResponseForSelect<NMLSReportEntity>() { ResponseCode = "2001", ResponseMessage = "No Records Found" };
}
For each datatable binding,I am calling seperate call in service.I have one datatable which containd more than 300 records.Sometimes it will show.and sometimes it wont..it will take more time to load.How to increase performance?Please help me...Its urgent..Reply soon :(