使用Juery plguin数据表创建一个包含动态超链接的列

时间:2017-05-17 08:50:48

标签: hyperlink datatable

我想使用超链接创建我的Site_ID列,当单击每个Site_ID时,它将链接到不同的页面。下面是我的代码,有人可以给我一些建议吗?

    var infoTable = $('#resultTable').dataTable({
        "processing"  : true,
        "serverSide"  : true,
        "scrollX"     : true,
        "jQueryUI"    : true,
        "deferRender" : true,
        "order"       : [[ 0, "asc" ]],
        "ajax": "./DataTables-1.10.15/examples/server_side/scripts/server_processing.php",                
        "pagingType"  : "full_numbers",
        "oLanguage"   : {
            "sSearch": "Search all columns:"
        },
        "aoColumns":[
            {
                "data":"Site_ID",
                "render": function ( data,type,full, meta ) {
                  return '<a href="'+data+'">'+data+'</a>';                             
                }
            },
            ]
      });

1 个答案:

答案 0 :(得分:0)

我得到了答案,它运行良好。

var infoTable = $(&#39;#resultTable&#39;)。dataTable({             &#34;处理&#34; :真的,             &#34;服务器侧&#34; :真的,             &#34; scrollX&#34; :真的,             &#34; jQueryUI的&#34; :真的,             &#34; deferRender&#34; :真的,             &#34;为了&#34; :[[0,&#34; asc&#34; ]]             &#34; ajax&#34;:&#34; ./ DataTables-1.10.15 / examples / server_side / scripts / server_processing.php&#34;,
            &#34; pagingType&#34; :&#34; full_numbers&#34;,             &#34; oLanguage&#34; :{                 &#34; sSearch&#34;:&#34;搜索所有列:&#34;             },             columnDefs:[                 {目标:[0],                   render:function(data){                     返回&#39; +数据+&#39;&#39;                   }                 }               ]           });