Quantcast
Viewing all articles
Browse latest Browse all 82145

Can not populate JQuery DataTable with my json data

I'm stuck completely while accessing the data from asp.net web service to .aspx page. I used the Newtonsoft.Json.JsonConvert.SerializeObject(qry, Formatting.Indented) for creating a JSON string.

This library provides a genuine and valid JSON string like following:
[ { "DepartmentId": 0, "Department": "CIVIL ENGG.", "DepartmentShortName": "CIVIL" },
{ "DepartmentId": 10, "Department": "COMPUTER SCIENCE ENGINEERING", "DepartmentShortName": "C.S.E." },
{ "DepartmentId": 21, "Department": "ELECTRICAL & ELECTRONICS ENGG.", "DepartmentShortName": "E.N." },
{ "DepartmentId": 31, "Department": "ELECTRONICS & COMMUNICATION ENGG.", "DepartmentShortName": "E.C.E" } ]

The code snippet to populate the datatable is:
$(document).ready(function() {
$.ajax({
type: "POST",
url: webServiceURL,
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(json) {
$('#grid').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": webServiceURL,
"fnServerData": fnDataTablesPipeline
});
}
});
});
for complete set of code, I referred the http://www.datatables.net/examples/server_side/pipeline.html link and indeed tried many other options but no luck.

I suspect that it can be occurred because of 'sEcho', 'iDisplayStart' and 'iDisplayLength' are missing from json but when I used my json string within aspx page and passed to 'aaData', it works fine.

I'm lost and not finding any solution since last three days. I believe some help will come out here..

Thanks in advance

Viewing all articles
Browse latest Browse all 82145

Trending Articles