解决方法
fnGetPosition
Get the array indexes of a particular
cell from it’s DOM element. Best used
in combination with fnGetData().
输入参数:
nNode : the node you want to find the
position of. This my be either a ‘TR’
row or a ‘TD’ cell from the table. The
return parameter depends on this
input.
返回参数:
int or array [ int,int,int ] : if
the node is a table row (TR) then the
return value will be an integer with
the index of the row in the aoData
object. If the node is a table cell
(TD) then the return value will be an
array with [ aoData index row,column
index (discounting hidden rows),column
index (including hidden rows) ].
代码示例:
$(document).ready(function() { $('#example tbody td').click( function () { /* Get the position of the current data from the node */ var aPos = oTable.fnGetPosition( this ); /* Get the data array for this row */ var aData = oTable.fnGetData( aPos[0] ); /* Update the data array and return the value */ aData[ aPos[1] ] = 'clicked'; this.innerHTML = 'clicked'; } ); /* Init DataTables */ oTable = $('#example').dataTable(); } );