【问题标题】:Concatinate Link and action in mDataProp在 mDataProp 中连接链接和操作
【发布时间】:2014-04-09 15:04:17
【问题描述】:

我正在使用 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,所以我只是在aoColumns 中获得deviceMacAddress 的值,例如:

"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>

现在我想知道,如何使用这个datatable 制作deviceMacAddress 的超链接。

【问题讨论】:

    标签: jquery jsp datatables jquery-datatables


    【解决方案1】:

    找到我的答案 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>';
          }
        } ]
      } );
    } );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-03
      • 1970-01-01
      • 2019-08-31
      • 1970-01-01
      相关资源
      最近更新 更多