我正在处理从 json 数据在 DataTable 中创建链接。事情会好起来,但链接名称似乎不正确。无论我试图改变什么,它都会一直说“未定义”。这是我的代码:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var oTable = $('#tablez').dataTable( {
"bProcessing": true,
"bJQueryUI": true,
"sAjaxSource": 'inc/all_cars_json.php',
"sPaginationType": "full_numbers",
"aaSorting": [[ 0, "desc" ]],
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
$('td:eq(1)', nRow).html('<a href="car/=' + nRow[0] + '">' +
nRow[1] + '</a>');
return nRow;
}
} );
} );
</script>
JSON数据:
{"aaData": [
["2715","Toyota","Soluna","VIOS 1.5E VVT-i","2007","\u0e14\u0e33","430,000"],
["2589","Toyota","","MIGHTY X","1995","\u0e40\u0e02\u0e35\u0e22\u0e27","159,000"],["2997","Mazda","Fighter","Freestyle CAB TURBO","2003","\u0e1a\u0e23\u0e2d\u0e19\u0e0b\u0e4c\u0e40\u0e07\u0e34\u0e19","329,000"],
["3002","Isuzu","Rodeo","LS 4WD","2000","\u0e1a\u0e23\u0e2d\u0e19\u0e0b\u0e4c\u0e17\u0e2d\u0e07","319,000"],
["3126","Toyota","Hilux","TIGER D4D CAB","2003","\u0e02\u0e32\u0e27","465,000"],["3127","Mitsubishi","Triton","DID Commonrail","2006","\u0e1a\u0e23\u0e2d\u0e19\u0e0b\u0e4c\u0e17\u0e2d\u0e07","455,000"],
["3128","Honda","City","1.5 i-VTEC","2009","\u0e14\u0e33","0"]
]}
这是预览:
问题是:在这种情况下,如何让链接标题和值 (nRow[0]) 起作用。问候,