Datatables Paging displaying all records in single page.

Datatables Paging displaying all records in single page.

Chintu535Chintu535 Posts: 2Questions: 1Answers: 0

I am using datatables to display records in pages.But all the records were displayed in the same page. I have been creating table dynamically by fetching data from database.
Below is the code for creating dynamic table

function CreateHtmlString(JSONObj) {

ChartObj = JSONObj;
GetHeaderString();
GetChartDataString();
return HtmlString;

}

function GetHeaderString() {
HtmlString = '

'; for (var i = 0; i < ChartObj.length; i++) { HtmlString += ''; } HtmlString += ''; } function GetChartDataString() { for (var i = 0; i < ChartObj[0].Data.ArrayData.length; i++) { HtmlString += '' for (var j = 0; j < ChartObj.length; j++) { HtmlString += ''; } HtmlString += ''; } HtmlString += '
' + ChartObj[i].Name + '
' + ChartObj[j].Data.ArrayData[i] + '

';
}

In HTML, I am writing to display paging for the table

$(document).ready(function () {
CreateChartTable();
$('#ChartData').dataTable({
});

});
function CreateChartTable() {
    var ChartData1 = JSON.parse('@ViewBag.ChartData'.replace(/&quot;/g, '"')); '@ViewBag.ChartData';
    document.getElementById('ChartTable').innerHTML = CreateHtmlString(ChartData1);

I would like to view results as per the number selected from dropdown.
Please help me out.

Thanks.

This discussion has been closed.