来自服务器的我的json数据
[
{
"INVESTORREF": null,
"PROCFLAG": "Processed",
"LOCKINBALANCE": 0,
"ISIN": "BD0401ALHAJ8",
"STATUS": "Pending",
"RECORDDATE": "\/Date(1417284000000)\/",
"EXCEPTIONDETAILS": null,
"ISEXCEPTION": null,
"ISCREDIT": "Y",
"SEQUENCENO": null,
"PREMIUM": null,
"FREEZEBALANCE": 0,
"CAID": "345d457a-a500-43e9-b935-faf889cbf14e",
"IMPORTDATE": "\/Date(1427000124666)\/",
"LASTUPDATED": "\/Date(1427000124666)\/",
"CATYPE": "BONUS",
"EFFECTIVEDATE": "\/Date(1326132000000)\/",
"BOID": "1205150002440950",
"FREEBALANCE": 5020,
"INSTRUMENTNAME": "Business Object Solutions",
"DRCRFLAG": "CREDIT"
}
]
我想在Jquery数据表中绑定这些数据
$('#myTable').dataTable();
如何将这个json数据与datatable绑定?需要帮助。 在此先感谢。
答案 0 :(得分:0)
这会有所帮助:
var jsonDataFromServer = [
{
"INVESTORREF": null,
"PROCFLAG": "Processed",
"LOCKINBALANCE": 0,
"ISIN": "BD0401ALHAJ8",
"STATUS": "Pending",
"RECORDDATE": "\/Date(1417284000000)\/",
"EXCEPTIONDETAILS": null,
"ISEXCEPTION": null,
"ISCREDIT": "Y",
"SEQUENCENO": null,
"PREMIUM": null,
"FREEZEBALANCE": 0,
"CAID": "345d457a-a500-43e9-b935-faf889cbf14e",
"IMPORTDATE": "\/Date(1427000124666)\/",
"LASTUPDATED": "\/Date(1427000124666)\/",
"CATYPE": "BONUS",
"EFFECTIVEDATE": "\/Date(1326132000000)\/",
"BOID": "1205150002440950",
"FREEBALANCE": 5020,
"INSTRUMENTNAME": "Business Object Solutions",
"DRCRFLAG": "CREDIT"
}
]
jsonDataFromServer = jsonDataFromServer[0];
var keys = Object.keys(jsonDataFromServer),
data = [];
$.each(keys, function(i, val){
data.push(new Array(val, jsonDataFromServer[val]));
});
$('#myTable').dataTable({
"data": data,
"columns": [
{ "title": "Name" },
{ "title": "Value" }
]
});
答案 1 :(得分:0)