从选定的行中获取列值
使用 DataTables 时,如何获取 fnGetNodes 返回的行的列值?我正在使用下面的函数返回选定的行。我想使用此函数的返回值从数据库中删除选定的行。但是,为此我需要每个选定行的 uniqueid 值。另一个潜在的问题是 uniqueid attr 标记为:
b可见:假
这样它实际上不会显示给用户,因为他们不感兴趣。
/* Get the rows that are selected */
function fnGetSelected( oTableLocal )
{
var aReturn = new Array();
var aTrs = oTableLocal.fnGetNodes();
for ( var i=0 ; i<aTrs.length ; i++ )
{
if ( $(aTrs[i]).hasClass('row_selected') )
{
aReturn.push( aTrs[i] );
}
}
return aReturn;
}
When using DataTables how do I get column values for the rows returned by fnGetNodes? I'm using the function below that returns the selected rows. I want to use the return value of this function to delete the selected rows from the database. However, to do that I need the uniqueid value of each selected row. One other potential problem is that the uniqueid attr is marked with:
bVisible: false
so that it isn't actually displayed to the user as it is of no interest to them.
/* Get the rows that are selected */
function fnGetSelected( oTableLocal )
{
var aReturn = new Array();
var aTrs = oTableLocal.fnGetNodes();
for ( var i=0 ; i<aTrs.length ; i++ )
{
if ( $(aTrs[i]).hasClass('row_selected') )
{
aReturn.push( aTrs[i] );
}
}
return aReturn;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要对 DataTable 使用 fnGetData() 方法。如果您传递选定的行,它将返回您想要的行的数组。
You would need to use the fnGetData() method for DataTable. If you pass the selected row it will return an array of the row that you want.