i trying implement simple datatables example using javascript object data source following template here (second example). please see code below:
$("#dynamicscenariotblcontainer div:last table").datatable({ //initialize table extras "data" : [{"nodata": "no data"}], "columns": [{ "data" : "nodata" }] }); although code seems follow same logic example getting
'uncaught typeerror: cannot read property 'length' of undefined'
update:
var dsdefaultsettings = '<table class="display compact" cellspacing="0" width="100%"><tr><thead></thead></tr><tbody></tbody>/table>'; $("#dynamicscenariotblcontainer").append("<div></div>") $("#dynamicscenariotblcontainer div:last").html(dsdefaultsettings); $("#dynamicscenariotblcontainer div:last table").datatable({ //initialize table extras "data": [{"nodata": "no data"}], "columns": [{ "data": "nodata" }] });
there no tbody element in table , thead should not encapsulated tr.
reference: http://www.w3schools.com/tags/tag_thead.asp
the correct html table should be:
var dsdefaultsettings = '<table class="display compact" cellspacing="0" width="100%"><thead></thead><tbody></tbody></table>';
Comments
Post a Comment