2012-12-29 35 views
0

我使用jQuery的DataTables插件(www.datatables.net)。如何細胞轉變像jQuery,數據錶轉換單元格

name www 
n1 w1 
n2 w2 
n3 w3 
name www 

becames到

name www 
n1 <a href="w1">w1</a> 
n2 <a href="w2">w2</a> 
n3 <a href="w3">w3</a> 
name www 

安裝在jQuery代碼是在這裏:

$(document).ready(function() { 
    $('#example').dataTable(); 
    $('#example').convertCell(setCell("<a href="getCell()">getCell()</a>"));//How to put it better? 
}); 

和HTML代碼是

<div id="dynamic"> 
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"> 
    <thead> 
     <tr> 
      <th width="15%">Name</th> 
      <th width="15%">Www</th> 
     </tr> 
    </thead> 
    <tbody></tbody> 
</table> 
</div> 

問候:初學者在數據表

回答

0

我不知道有關該插件,但是你可以使用:

$('.example').each(function(){ 
    $(this).wrap(function() { 
     return '<a href="' + $(this).text() + '" />'; 
    }); 
}); 

會在指向每個文本鏈接包裝每個元素與類.example

+1

我發現自己\t 「aoColumnDefs」:[{ 「aTargets」:[1], 「fnCreatedCell」:功能(NTD,SDATA,ODATA,iRow,ICOL){$ (NTD)的.html(」 '+sData+'')}} – user1929552

+0

@ user1929552 dats爲你工作? –