我正在使用Jquery Datatable服务器端分页。有一个属性deviceMacAddress
。当我之前使用display:table
时,我正在制作deviceMacAddress
超链接,其动作如下:
<display:column title="Mac Address" media="html" style="text-align:center;">
<s:url id="deviceInfoByMac" action="fetchMacSummaryPage">
<s:param name="deviceMacAddress" value="%{#attr.row.deviceMacAddress}" />
</s:url>
<s:a href="%{deviceInfoByMac}" style="color: mediumblue;">
<s:property value="%{#attr.row.deviceMacAddress}"/>
</s:a>
</display:column>
现在,当我使用datatable
时,我只是在deviceMacAddress
中获得aoColumns
的值,如:
"aoColumns": [ { "mDataProp": "deviceMacAddress"},
{ "mDataProp": "deviceName"},
{ "mDataProp": "facilityName"},
{ "mDataProp": "type"},
{ "mDataProp": "language"},
{ "mDataProp": "target"},
{ "mDataProp": "status"},
{ "mDataProp": "dateProcessed"} ]
我的jsp文件只有这些列的标题,如:
<table id="row">
<thead>
<tr>
<th>Mac Address</th>
<th>Device Name</th>
<th>Facility</th>
<th>Module</th>
<th>Language</th>
<th>Resource Requested</th>
<th>Email Status</th>
<th>Email Sent On</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
现在我想知道,如何使用此deviceMacAddress
制作datatable
的超链接。
答案 0 :(得分:0)
找到我的答案Here,mRender
是我想知道的解决方案。
// Use as a function to create a link from the data source
$(document).ready( function() {
var oTable = $('#example').dataTable( {
"aoColumnDefs": [ {
"aTargets": [ 0 ],
"mData": "download_link",
"mRender": function ( data, type, full ) {
return '<a href="'+data+'">Download</a>';
}
} ]
} );
} );