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

New: cell invalidation methods

- New API methods:
  - cell().invalidate() - Invalidate a single cell
  - cells().invalidate() - Invalidate multiple cells

- Note that the invalidation is actually row based, rather than cell
  based - i.e. the whole row is invalidated. This may change in future
  versions of DataTables, but I'm concerned that it would add a lot of
  code for little enhancement.
This commit is contained in:
Allan Jardine 2013-05-19 08:43:45 +01:00
parent 643930c33d
commit 1590f41525
2 changed files with 33 additions and 2 deletions

View File

@ -10,7 +10,7 @@ _api.register( 'cells()', function ( rowSelector, columnSelector, opts ) {
var rows = this.rows( rowSelector, opts );
var a, i, ien, j, jen;
return this.iterator( 'table', function ( settings, idx ) {
var cells = this.iterator( 'table', function ( settings, idx ) {
a = [];
for ( i=0, ien=rows[idx].length ; i<ien ; i++ ) {
@ -24,6 +24,14 @@ _api.register( 'cells()', function ( rowSelector, columnSelector, opts ) {
return a;
} );
$.extend( cells.selector, {
cols: columnSelector,
rows: rowSelector,
opts: opts
} );
return cells;
} );
@ -41,6 +49,18 @@ _api.register( 'cells().data()', function () {
} );
_api.register( 'cells().invalidate()', function ( src ) {
var selector = this.selector;
// Use the rows method of the instance to perform the invalidation, rather
// than doing it here. This avoids needing to handle duplicate rows from
// the cells.
this.rows( selector.rows, selector.opts ).invalidate( src );
return this;
} );
_api.register( 'cell()', function ( rowSelector, columnSelector, opts ) {
@ -73,6 +93,17 @@ _api.register( 'cell().data()', function ( data ) {
} );
_api.register( 'cell().invalidate()', function ( src ) {
var ctx = this.context;
if ( ctx.length && this.length ) {
_fnInvalidateRow( ctx[0], this[0].row, src );
}
return this;
} );
}());

View File

@ -39,7 +39,7 @@ _api.register( 'row().cells()', function () {
_api.register( 'row().data()', function ( data ) {
var ctx = this.context;
if ( data === undefined ) ) {
if ( data === undefined ) {
// Get
return ctx.length && this.length ?
ctx[0].aoData[ this[0] ]._aData :