我刚用服务器端脚本检查了bootstrap数据表。在这里,我使用POST数据来显示我的数据表。没问题,为我工作正常。
这是我的javascript部分 -
$('#list-account').dataTable({
"processing": true,
"serverSide": true,
"ajax": {
"url": "includes/process_list_account.php",
"type": "POST"
},
"columns": [
{ "data": "domain_name" },
{ "data": "username" },
{ "data": "contact_email" },
{ "data": "contact_number" },
{ "data": "date_registered" },
{ "data": "domain_expired", "class": "text-center"}
]
});
我的问题是如何显示两个静态表列以及后期数据。一个用于表中所有行的相同图像,另一个用于指向所有行的相同链接。有可能吗?
这样的事情 -
<tr>
<td>....</td>
<td>....</td>
<td>....</td>
<td>....</td>
<td>....</td>
<td>....</td>
<td><a href="mylink.html">my link</a></td>
<td><a href=""><img src="images/icon.png"></a></td>
</tr>
<tr>
<td>....</td>
<td>....</td>
<td>....</td>
<td>....</td>
<td>....</td>
<td>....</td>
<td><a href="mylink.html">my link</a></td>
<td><a href=""><img src="images/icon.png"></a></td>
</tr>
<tr>
<td>....</td>
<td>....</td>
<td>....</td>
<td>....</td>
<td>....</td>
<td>....</td>
<td><a href="mylink.html">my link</a></td>
<td><a href=""><img src="images/icon.png"></a></td>
</tr>
更新:
我用columns.render
-
$('#cpanel-account').dataTable({
"processing": true,
"serverSide": true,
"ajax": {
"url": "includes/process_cpanel_details.php",
"type": "POST"
},
"columns": [
{ "data": "domain_name" },
{ "data": "cpanel_username" },
{ "data": "cpanel_password" },
{ "targets": 0, "data": "download_link", "render": function ( data, type, full, meta ) {
return '<a href="'+data+'">Download</a>';
}
}
]
});
希望有人可以帮助我。谢谢。