获取DataTables中选中行的行值

发布于 2024-12-11 17:08:03 字数 162 浏览 3 评论 0原文

我画了一个数据表,每行都有复选框。现在,当我选择某些复选框并单击“提交”时,我想获取整行中所有列的值。

我尝试使用 $('tr input',oTable.fnGetNodes()).serialize(); ,但这仅返回复选框的值。 我怎样才能获得整个选中行的值。

I have painted a datatable with checkbox's against each row. Now when i select certain checkboxes and click submit , I want to get the value of all the columns in the entire row.

I tried using $('tr input',oTable.fnGetNodes()).serialize(); , but this returned only the value of the checkbox.
How can i get the value of the entire checked row.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ゝ杯具 2024-12-18 17:08:03

解决了问题。

循环遍历数据表中的每个 tr 行,并使用

$('#DataTable tr').each(function() {    
          var rowData = this.cells

rowData 获取包含每个单元格值的数组。rowData 是一个包含每个单元格值的数组。因为复选框是第一列,从 rowData 数组中获取第一列的值,如下所示

rowData[0].firstChild.value

Resolved the issue.

Looped over each of the tr rows in the Datatables, and got the an array containing value of each cell using

$('#DataTable tr').each(function() {    
          var rowData = this.cells

rowData is an array which contains the values of each of the cells.Since the checkbox was the first column , got the value of the first column from the rowData array like this

rowData[0].firstChild.value
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文