Question

I've got such json data

{ "aaData" : [
   [ { "field1" : "value11", "field2" : "value12", "field3" : "value13" },
     { "field1" : "value21", "field2" : "value22", "field3" : "value33" } ]
]}

How to load such data into datatable? My init function looks like this

var oTable1 = $('#usertable').dataTable({
    "sPaginationType": "bs_full",
    "bProcessing" : true,
    "sAjaxSource" : "loadusers.html" });

And in html

<table class="datatable table table-striped table-bordered" id="usertable">
                        <thead>
                            <th>Field1</th>
                            <th>Field2</th>
                            <th>Field3</th>
                        </thead>
                        <tbody></tbody>
                    </table>

No correct solution

OTHER TIPS

Have you considered using JQGrid? it can create nice table from JSON.

http://www.trirand.com/blog/ (check out the demo).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top