引用数据表中的嵌套JSON对象

时间:2013-05-06 06:17:10

标签: jquery ajax json object datatables

我有以下JSON:

[
       {
       "id":"78",
        "packaging": "0",
        "created_at": "2013-01-28 13:46:41",
        "updated_at": "2013-01-28 13:46:41",
        "Clients": {
                      "id": "6",
                      "Name": "Some Name",
                      "Address": "0000000",
                      "Email":"email@somedomain.com"
           }
     },
     {
       "id":"79",
        "packaging": "0",
        "created_at": "2013-01-28 13:46:41",
        "updated_at": "2013-01-28 13:46:41",
        "Clients": {
                      "id": "9",
                      "Name": "Some Other Name",
                      "Address": "0000001",
                      "Email":"email@someotherdomain.com"
           }
     }
]

我已经在Jsonlint.com上验证它是有效的JSON。

我设法引用了unnested数据,如下所示:

    {"sTitle":"Id","mData":"id"},
    {"sTitle":"Created At","mData":"created_at"},
    {"sTitle":"Updated At.","mData":"updated_at"},

现在我希望能够在数据表中引用客户端名称。

如何使用mData

执行此操作

1 个答案:

答案 0 :(得分:2)

试试这个 -

{"sTitle":"Client ID","mData":"Clients.id"},
{"sTitle":"Client Name","mData":"Clients.Name"},
{"sTitle":"Client Address","mData":"Clients.Address"}