1
0
mirror of https://github.com/DataTables/DataTables.git synced 2024-12-01 13:24:10 +01:00

New: table() API methods

- New API methods:
  - table() - select a single table
  - table().node() - get the table node for the table

- To be honest, these methods are not likely to be used particuarly
  often, so I think they are fairly low priority, but they could provide
  useful, and it is a public way to get the table node.
This commit is contained in:
Allan Jardine 2013-05-18 17:39:03 +01:00
parent d7b12bd83b
commit 903d1219f3
2 changed files with 24 additions and 1 deletions

View File

@ -18,7 +18,7 @@ _api.register( 'row()', function ( selector, opts ) {
_api.register( 'row().node()', function () {
var ctx = this.context;
if ( ctx.length && this.length ) {
return ctx[0].aoData[ this[0] ].nTr || undefined;
}

View File

@ -36,5 +36,28 @@ _Api.register( 'tables().nodes()', function () {
} );
_Api.register( 'table()', function ( selector ) {
var tables = this.tables( selector );
var ctx = tables.context;
// Truncate to the first matched table
if ( ctx.length ) {
ctx.length = 1;
}
return tables;
} );
_Api.register( 'table().node()', function () {
var ctx = this.context;
if ( ctx.length ) {
return ctx[0].nTable;
}
// return undefined;
} );
}());