jQuery-数据表,如何获取列ID [英] jQuery - datatables, how to get column id
问题描述
如何在jquery的数据表插件中获取列ID,我需要用于数据库更新的列ID.
How to get a column id in datatable plugin for jquery I need column id for the update in database.
推荐答案
fnGetPosition
获取特定数组的索引 来自其DOM元素的单元格.最好用的 结合fnGetData().
Get the array indexes of a particular cell from it's DOM element. Best used in combination with fnGetData().
输入参数:
nNode:您要查找的节点 的位置.这可能是我的"TR" 行或表格中的"TD"单元格.这 返回参数取决于此 输入.
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或数组[int,int,int]:如果 节点是表行(TR),则 返回值将是一个整数 aoData中行的索引 目的.如果节点是表单元格 (TD),则返回值将是 具有[aoData索引的行,列的数组 索引(为隐藏行减价),列 索引(包括隐藏的行)].
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();
} );
这篇关于jQuery-数据表,如何获取列ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!