DataTable with server side with C#
DataTable with server side with C#
milindsaraswala
Posts: 3Questions: 0Answers: 0
I am trying to load DataTable from server side code is in C# and is doing from webservice. I am getting proper jSON. But I am getting error length is undefined.
My jSON output
[code]
{"sEcho":"1","aoData":[{"civilID":"123456789012","firstName":"Adel","lastName":"Alshammeri","mobile":"99466444","parentID":"","rowNum":1},{"civilID":"267122700454","firstName":"Adel","lastName":"S","mobile":"99466444","parentID":"","rowNum":2},{"civilID":"275030107784","firstName":"Mahfuz","lastName":"S","mobile":"66390129","parentID":"267122700454","rowNum":3},{"civilID":"265103002897","firstName":"Antonio","lastName":"S","mobile":"99073592","parentID":"267122700454","rowNum":4},{"civilID":"272110203967","firstName":"Reco","lastName":"S","mobile":"50956026","parentID":"267122700454","rowNum":5},{"civilID":"259061403367","firstName":"Eliseo","lastName":"S","mobile":"50956026","parentID":"275030107784","rowNum":6},{"civilID":"265020307919","firstName":"Liza","lastName":"S","mobile":"66642749","parentID":"275030107784","rowNum":7},{"civilID":"244101000772","firstName":"AlAsmar","lastName":"S","mobile":"99089648","parentID":"275030107784","rowNum":8},{"civilID":"273100700825","firstName":"Alhadad","lastName":"S","mobile":"60993977","parentID":"265103002897","rowNum":9},{"civilID":"268082304389","firstName":"AILEEN","lastName":"s","mobile":"66481975","parentID":"265103002897","rowNum":10}],"iTotalRecords":"42","iTotalDisplayRecords":"42"}
[/code]
and My javascript code is
[code]
$(document).ready(function () {
$("#org").jOrgChart({
chartElement: '#chart',
dragAndDrop: false
});
$('#members').dataTable({
"bServerSide": true,
"sAjaxSource": "CivilID.aspx/getData",
"sAjaxDataProp": "",
"bProcessing": true,
"bDestroy": true,
"fnServerData": function (sSource, aoData, fnCallback) {
$.ajax({
"dataType": 'json',
"contentType": "application/json; charset=utf-8",
"type": "GET",
"url": sSource,
"data": aoData,
"success": function (msg) {
var json = jQuery.parseJSON(msg.d);
fnCallback(json);
//$("#members").show();
}
});
},
"aoColumns": [
{ "sName": "civilID" },
{ "sName": "firstName" },
{ "sName": "lastName" },
{ "sName": "mobile" },
{ "sName": "parentID" },
{ "sName": "rowNum" }
]
});
});
[/code]
Kindly can somebody help me what I am doing wrong
My jSON output
[code]
{"sEcho":"1","aoData":[{"civilID":"123456789012","firstName":"Adel","lastName":"Alshammeri","mobile":"99466444","parentID":"","rowNum":1},{"civilID":"267122700454","firstName":"Adel","lastName":"S","mobile":"99466444","parentID":"","rowNum":2},{"civilID":"275030107784","firstName":"Mahfuz","lastName":"S","mobile":"66390129","parentID":"267122700454","rowNum":3},{"civilID":"265103002897","firstName":"Antonio","lastName":"S","mobile":"99073592","parentID":"267122700454","rowNum":4},{"civilID":"272110203967","firstName":"Reco","lastName":"S","mobile":"50956026","parentID":"267122700454","rowNum":5},{"civilID":"259061403367","firstName":"Eliseo","lastName":"S","mobile":"50956026","parentID":"275030107784","rowNum":6},{"civilID":"265020307919","firstName":"Liza","lastName":"S","mobile":"66642749","parentID":"275030107784","rowNum":7},{"civilID":"244101000772","firstName":"AlAsmar","lastName":"S","mobile":"99089648","parentID":"275030107784","rowNum":8},{"civilID":"273100700825","firstName":"Alhadad","lastName":"S","mobile":"60993977","parentID":"265103002897","rowNum":9},{"civilID":"268082304389","firstName":"AILEEN","lastName":"s","mobile":"66481975","parentID":"265103002897","rowNum":10}],"iTotalRecords":"42","iTotalDisplayRecords":"42"}
[/code]
and My javascript code is
[code]
$(document).ready(function () {
$("#org").jOrgChart({
chartElement: '#chart',
dragAndDrop: false
});
$('#members').dataTable({
"bServerSide": true,
"sAjaxSource": "CivilID.aspx/getData",
"sAjaxDataProp": "",
"bProcessing": true,
"bDestroy": true,
"fnServerData": function (sSource, aoData, fnCallback) {
$.ajax({
"dataType": 'json',
"contentType": "application/json; charset=utf-8",
"type": "GET",
"url": sSource,
"data": aoData,
"success": function (msg) {
var json = jQuery.parseJSON(msg.d);
fnCallback(json);
//$("#members").show();
}
});
},
"aoColumns": [
{ "sName": "civilID" },
{ "sName": "firstName" },
{ "sName": "lastName" },
{ "sName": "mobile" },
{ "sName": "parentID" },
{ "sName": "rowNum" }
]
});
});
[/code]
Kindly can somebody help me what I am doing wrong
This discussion has been closed.
Replies
[code]
Civil ID
First Name
Last Name
Mobile
Parent ID
Row Number
[/code]