0
填充數據表的標頭值我有JSON如下所示從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填充標題名稱。 (名稱,說明,日期)。我怎樣才能做到這一點。
任何想法???
在此先感謝!
「列」:[ { 「sTitle」:「標題名稱」, } ]。 sTitle做了詭計,謝謝 –