将json数据加载到datatable中

时间:2014-03-03 11:24:49

标签: jquery datatable

我有这样的json数据

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

如何将这些数据加载到datatable中? 我的init函数看起来像这个

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

并在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>

1 个答案:

答案 0 :(得分:0)

你考虑过使用JQGrid吗?它可以从JSON创建漂亮的表。

http://www.trirand.com/blog/(查看演示)。