我有如下所示的json
{
"aaData": [
[
"Name",
"Description",
"Date"
],
[
{
"displayValue": "Home Page",
"link": "http://somelink.com"
},
"London",
"1983"
],
[
{
"displayValue": "Backlog",
"link": "http://BacklogApp.com"
},
"Paris",
"1999"
]
]
}
现在在 js 中,我使用 sAjaxSource 填充表,如下所示
$(document).ready(function() {
$('#genericTable').dataTable( {
"bProcessing": true,
"sAjaxSource": "resources/json/" + key + ".json",
"sPaginationType" : "full_numbers",
"bJQueryUI" : true,
"bRetrieve" : true,
"bPaginate" : true,
"bSort" : true,
"aaSorting" : [[ 3, "desc" ]],
"iDisplayLength" : 50,
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
if(typeof aData[0] != 'string'){
$('td:eq(0)', nRow).html( '<a href="' + aData[0]['link'] +'" >' +
aData[0]['displayValue'] + '</a>');
}
}
}).columnFilter({ sPlaceHolder: "head:after",
aoColumns: [ { type: "text" },
{ type: "text" },
null
]
});
});
我可以在 jsp 中使用硬编码的标题名称填充表中的数据,但我也想从 json 填充标题名称。(名称、描述、日期)。我怎样才能做到这一点。
任何想法???
提前致谢!