以下に示すような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 からもヘッダー名を入力したいと考えています。(名前、説明、日付)。これどうやってするの。
何か案が???
前もって感謝します!