2014-03-03 40 views
0

我有这样的JSON数据负载JSON数据到数据表

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

如何这样的数据加载到数据表? 我的初始化函数看起来像这样

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> 

回答

0

你有没有考虑过使用的jqGrid?它可以从JSON创建漂亮的表格。

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

+0

也 - 这是你所寻找的相同? - http://stackoverflow.com/questions/1051061/convert-json-array-to-an-html-table-in-jquery –