DataTables warning: Requested unknown parameter '0' from the data source for row '0' -


does please know, wrong simple html file below?

enter image description here

i trying use an array of objects data source datatables:

tests.html:

<html> <head> <link type="text/css" rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/redmond/jquery-ui.css"> <link type="text/css" rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/jquery.datatables/1.9.2/css/jquery.datatables_themeroller.css"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script> <script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery.datatables/1.9.2/jquery.datatables.min.js"></script> <script type="text/javascript">  var data = [     {"name":"updatebootprofile","result":"pass","executiontime":"00:00:00","measurement":[]},     {"name":"nrb boot","result":"pass","executiontime":"00:00:50.5000000","measurement":[{"testname":"total_turn_on_time","result":"pass","value":"50.5","lowerlimit":"nan","upperlimit":"nan","comparisontype":"nctlog","units":"seconds"}]},     {"name":"nvmgrcommit","result":"pass","executiontime":"00:00:00","measurement":[]},     {"name":"syncnvtoefs","result":"pass","executiontime":"00:00:01.2500000","measurement":[]} ];  $(function() {         var teststable = $('#tests').datatable({                 bjqueryui: true,                 aadata: data,                 aocolumns: [                         { mdata: 'name' },                         { mdata: 'result' },                         { mdata: 'executiontime' }                 ]         }); });  </script> </head> <body>  <table id="tests"> <thead> <tr> <th>name</th> <th>result</th> <th>executiontime</th> </tr> </thead> <tbody> </tbody> </table>  </body> </html> 

update: ok, i've got answer author to use newer version of datatables or rename mdata mdataprop

you're using array of objects. can use 2 dimensional array instead?

http://www.datatables.net/examples/data_sources/js_array.html

see jsfiddle: http://jsfiddle.net/qhyse/

i used array , worked fine:

var data = [     ["updatebootprofile","pass","00:00:00",[]] ,     ["nrb boot","pass","00:00:50.5000000",[{"testname":"total_turn_on_time","result":"pass","value":"50.5","lowerlimit":"nan","upperlimit":"nan","comparisontype":"nctlog","units":"seconds"}]] ,     ["nvmgrcommit","pass","00:00:00",[]] ,     ["syncnvtoefs","pass","00:00:01.2500000",[]] ]; 

edit include array of objects

there's possible solution question: jquery datatables fnrender objects

this jsfiddle http://jsfiddle.net/j2c7j/ uses array of objects. not error had pad 3 blank values - less optimal, know. may find better way fnrender, please post if do.

var data = [    ["","","", {"name":"updatebootprofile","result":"pass","executiontime":"00:00:00","measurement":[]} ]  ];  $(function() {         var teststable = $('#tests').datatable({                 bjqueryui: true,                 aadata: data,                 aocolumns: [                         { mdata: 'name', "fnrender": function( oobj ) { return oobj.adata[3].name}},                         { mdata: 'result' ,"fnrender": function( oobj ) { return oobj.adata[3].result }},                         { mdata: 'executiontime',"fnrender": function( oobj ) { return oobj.adata[3].executiontime } }                 ]         }); }); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -