连接mDataProp中的链接和操作

时间:2014-04-09 15:04:18

标签: jquery jsp datatables jquery-datatables

我正在使用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的超链接。

1 个答案:

答案 0 :(得分:0)

找到我的答案HeremRender是我想知道的解决方案。

// 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>';
      }
    } ]
  } );
} );