Jquery DataTables get Tabular data and row data

Source: Internet
Author: User

Note that the table variable is

1.jQuery DataTables line number get

$ ("#example tbody tr"). On ("click", Function () {
var index = $ (this). Context._dt_rowindex; Line number
});

2. Get all the data in the table

    1. function Gettablecontent () {
    2. var ntrs = Table.fngetnodes (); //fngetnodes Gets the table all rows, Ntrs[i] represents the line I TR object
    3. For (var i = 0; i < ntrs.length; i++) {
    4. Console.log (' [Get data] ' + table.fngetdata (ntrs[i])); Fngetdata get a row of data
    5. }
    6. }

3. Get table selected row data

  1. function Gettablecontent () {
  2. var ntrs = Table.fngetnodes (); //fngetnodes Gets the table all rows, Ntrs[i] represents the line I TR object
  3. For (var i = 0; i < ntrs.length; i++) {
  4. if ($ (ntrs[i]). Hasclass (' selected ')) {
  5. Console.log (' [Get data] ' + table.fngetdata (ntrs[i])); Fngetdata get a row of data
  6. }
  7. }
  8. }

4. Get a column of data for a row

  1. function Gettablecontent () {
  2. var ntrs = Table.fngetnodes (); //fngetnodes Gets the table all rows, Ntrs[i] represents the line I tr
  3. For (var i = 0; i < ntrs.length; i++) {
  4. if ($ (ntrs[i]). Hasclass (' selected ')) {//equivalent to $ (TR)
  5. var t = table.fngetdata (ntrs[i]);
  6. Console.log ("aaaaaa:" + t[2]); Get row 3rd column data
  7. // }  
  8. }
  9. }

Jquery DataTables get Tabular data and row data

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.