1
我有一个HTML表格HTML链接:的Javascript数据表生成使用渲染功能的JSON数据
<table id="dattable" class="table table-striped table-bordered hover" cellspacing="0" >
<thead>
<tr>
<th>Name</th>
<th>Industry</th>
<th>Cost</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
,它是由JSON数据填充。我想使用render函数使名称列中的项目具有使用id字段的HTML链接,但它不起作用。
var data2 =[
{
"id": "0",
"name": "Jack Spicer",
"industry__name": "System Architect",
"cost": "$3,120",
},
{
"id":"1",
"name": "Sean Spice",
"industry__name": "Motormouth",
"cost": "-$5,300",
}
];
$(document).ready(function() {
var table = $('#dattable').DataTable({
data: data,
columns: [
{ data: 'name', "render": "<a href =" + [, ].id +">"+[, ].name+"</a>"}, //render function
{ data: 'industry__name' },
{ data: 'cost' }
],
});
});
感谢该文档是有点混乱。 – ccsv
我同意,很高兴帮助。 – rolspace