jQuery – datatables,如何获取列ID

如何获取jQuery的datatable插件中的列ID我需要数据库中更新的列ID。

解决方法

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();
} );

datatables.net

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...