Can't initialize DataTable in html
Can't initialize DataTable in html
moromer
Posts: 3Questions: 1Answers: 0
Hi
In my HTML via JS from Nodejs server I receive stringifyed array and put in var = data2
Then prepare the template and compile it via Handlebars
<body>
<!-- <table id="table_id" class="display"></table> -->
<div id="source"></div>
<script id="table_id" type="text/x-handlebars-template">
<table id="example" class="display">
</table>
</script>
$(document).ready( function () {
var source = $("#table_id").html();
var profileTemplate = Handlebars.compile(source);
var renderTemplate = profileTemplate(data);
$("#source").html(renderTemplate);
$('#example').DataTable(
{
"source": data2,
"columns": [
{ "title": "field1" },
{ "title": "field2" },
{ "title": "field3" },
{ "title": "field4" },
{ "title": "field5" },
{ "title": "field6" },
{ "title": "field7" },
{ "title": "field8" },
{ "title": "field9" },
{ "title": "field10" },
{ "title": "field11" },
{ "title": "field12" },
{ "title": "field13" },
{ "title": "field14" }
]
});
} );
But at the end table is empty. can't solve it for several days in a row, need help. Thanks
debug Data is here: https://debug.datatables.net/esapib
This discussion has been closed.
Answers
Solved by changing option type in line 16 to 'data'
Initialized a table, but painted it with an error
https://datatables.net/manual/tech-notes/4 which means that DataTables tries to obtain data for a cell and is unable to do so
Unfortunately I don't see where the problem is. Therefore the thread is still active
What does your data2 object look like?