Datatable not working for morethan 500 rows
Datatable not working for morethan 500 rows
santosh6681
Posts: 4Questions: 0Answers: 0
hi,
i am using datatable 1.9 and using json web service as data source.it working fine for below 500 rows but not working for more than that.any help would be appreciated.
thanks and regards
i am using datatable 1.9 and using json web service as data source.it working fine for below 500 rows but not working for more than that.any help would be appreciated.
thanks and regards
This discussion has been closed.
Replies
$(document).ready(function () {
function renderTable(result) {
var dtData = [];
$.each(result, function () {
dtData.push([
this.rank,
this.name,
this.LW_amount,
this.LW_units,
this.CW_amount,
this.CW_units
]);
});
$('#grid').dataTable({ //grid is the id of the table
'aaData': dtData,
//'fnRowCallback': function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
//if (aData[2] > 20000) {
// $('td:eq(0)', nRow).addClass('conditionalRowColor');
//$('td:eq(1)', nRow).addClass('conditionalRowColor');
//$('td:eq(2)', nRow).addClass('conditionalRowColor');
//$('td:eq(3)', nRow).addClass('conditionalRowColor');
//$('td:eq(4)', nRow).addClass('conditionalRowColor');
//$('td:eq(5)', nRow).addClass('conditionalRowColor');
// }
//return nRow;
//},
'bFilter': true,
'bLengthChange': true,
"aoColumns": [{ "sClass": "right" }, { "sClass": "left" }, { "sClass": "right" }, { "sClass": "right" }, { "sClass": "right" }, { "sClass": "right"}],
'sPaginationType': 'full_numbers',
'iDisplayLength':5,
"fnDrawCallback": function () {
if ($("#grid").find("tr:not(.ui-widget-header)").length <= 5) {
$('div.dataTables_paginate')[0].style.display = "none";
} else {
$('div.dataTables_paginate')[0].style.display = "block";
}
}
});
}
$.ajax({
type: "GET",
url: "http://localhost:1504/WebService1.asmx/Getsales",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
renderTable(response.d);
},
failure: function (errMsg) {
$('#errorMessage').text(errMsg); //errorMessage is id of the div
}
});
});
Allan
I'd very much suggest you have a look at this blog post and use DataTables built in Ajax source options along with deferred rendering to see things up massively: http://datatables.net/blog/Extended_data_source_options_with_DataTables
Did you try changing to using the DataTables Ajax with sAjaxSource and mData ?
Allan