MY JSON格式:
{
"Tower1": [
{
"Core": "1",
"RadioActivity_Warning": "10",
"RadioActivity_Critical": "80"
},
{
"Core": "2",
"RadioActivity_Warning": "10",
"RadioActivity_Critical": "80"
}
]
}
我的jQuery功能如下。
function LoadThresholdInformation(data) {
$(TABLE).dataTable({
bPaginate : false,
bDestroy : true,
bFilter : false,
bInfo : false,
sScrollY: "100%",
sScrollX: "100%",
bInfinite: true,
aaData: data,
aoColumns : [
{fnRender: function (oObj) {
return "'"+oObj.aData.Tower1[0].Core+"'"; ///not working?
}, mDataProp: 'Core', sDefaultContent: '' },
{mDataProp: 'RadioActivity_Warning',},
{mDataProp: 'RadioActivity_Critical',},
],
});
}
此处return "'"+oObj.aData.Tower1[0].Core+"'";
不会返回任何内容。
答案 0 :(得分:0)
<强>解强>
请改用以下代码:
function LoadThresholdInformation(data) {
$(TABLE).dataTable({
bPaginate : false,
bDestroy : true,
bFilter : false,
bInfo : false,
sScrollY: "100%",
sScrollX: "100%",
bInfinite: true,
aaData: data,
aoColumns : [
{
mRender: function (data, type, full){
return "'" + data + "'";
},
mDataProp: 'Core',
sDefaultContent: ''
},
{mDataProp: 'RadioActivity_Warning'},
{mDataProp: 'RadioActivity_Critical'}
]
});
}