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
- function Gettablecontent () {
- var ntrs = Table.fngetnodes (); //fngetnodes Gets the table all rows, Ntrs[i] represents the line I TR object
- For (var i = 0; i < ntrs.length; i++) {
- Console.log (' [Get data] ' + table.fngetdata (ntrs[i])); Fngetdata get a row of data
- }
- }
3. Get table selected row data
- function Gettablecontent () {
- var ntrs = Table.fngetnodes (); //fngetnodes Gets the table all rows, Ntrs[i] represents the line I TR object
- For (var i = 0; i < ntrs.length; i++) {
- if ($ (ntrs[i]). Hasclass (' selected ')) {
- Console.log (' [Get data] ' + table.fngetdata (ntrs[i])); Fngetdata get a row of data
- }
- }
- }
4. Get a column of data for a row
- function Gettablecontent () {
- var ntrs = Table.fngetnodes (); //fngetnodes Gets the table all rows, Ntrs[i] represents the line I tr
- For (var i = 0; i < ntrs.length; i++) {
- if ($ (ntrs[i]). Hasclass (' selected ')) {//equivalent to $ (TR)
- var t = table.fngetdata (ntrs[i]);
- Console.log ("aaaaaa:" + t[2]); Get row 3rd column data
- // }
- }
- }
Jquery DataTables get Tabular data and row data