From bea47e6470035a83e97c194fe5fa315965a92f92 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Fri, 24 May 2013 07:57:41 +0100 Subject: [PATCH] New: columns and cell index() API methods - The row()/rows() methods have index methods, so it makes sense that the column(s) and cell(s) methods also have index methods to get the raw information out of the table. Rather than shying away from the indexes in 1.10, as has been done with the pervious versions of DataTables, 1.10 will embrase them as first class citizens. - New methods: - columns().index() - column().index() - cells().index() - cell().index() --- media/src/api/api.cells.js | 11 +++++++++++ media/src/api/api.columns.js | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/media/src/api/api.cells.js b/media/src/api/api.cells.js index d7174d41..241bb15b 100644 --- a/media/src/api/api.cells.js +++ b/media/src/api/api.cells.js @@ -67,6 +67,17 @@ _api.register( 'cells().data()', function () { } ); +_api.registerPlural( 'cells().index()', 'cell().index()', function () { + return this.iterator( 'cell', function ( settings, row, column ) { + return { + row: row, + column: column, + columnVisible: _fnColumnIndexToVisible( settings, column ) + }; + } ); +} ); + + _api.register( [ 'cells().invalidate()', 'cell().invalidate()' diff --git a/media/src/api/api.columns.js b/media/src/api/api.columns.js index 644a66c9..3a1efa79 100644 --- a/media/src/api/api.columns.js +++ b/media/src/api/api.columns.js @@ -117,6 +117,16 @@ _api.registerPlural( 'columns().visible()', 'column().visible()', function ( vis } ); + +_api.registerPlural( 'columns().index()', 'column().index()', function ( type ) { + return this.iterator( 'column', function ( settings, column ) { + return type === 'visible' ? + _fnColumnIndexToVisible( settings, column ) : + column; + } ); +} ); + + // _api.register( 'columns().show()', function () { // var selector = this.selector; // return this.columns( selector.cols, selector.opts ).visible( true );