Datatables Paging displaying all records in single page.
Datatables Paging displaying all records in single page.
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 = '
' + ChartObj[i].Name + ' | '; } HtmlString += '
---|
' + ChartObj[j].Data.ArrayData[i] + ' | '; } HtmlString += '
';
}
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(/"/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.