mirror of
https://github.com/DataTables/DataTables.git
synced 2024-11-29 11:24:10 +01:00
New: rows().remove() API method
- Remove (delete) selected rows from the table. - This effectively replaces the fnDeleteRow API method of the old API.
This commit is contained in:
parent
a767c05f1d
commit
2b0a321dd2
@ -57,5 +57,39 @@ _api.register( 'rows().data()', function ( data ) {
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
|
_api.register( 'rows().remove()', function () {
|
||||||
|
var that = this;
|
||||||
|
|
||||||
|
// Needs either a corrector to correct for deleted row indexes, or
|
||||||
|
// need to order and reverse so indexing is maintained for the row
|
||||||
|
// indexes. Damn
|
||||||
|
// @todo
|
||||||
|
return this.iterator( true, 'row', function ( settings, row, thatIdx ) {
|
||||||
|
var data = settings.aoData;
|
||||||
|
|
||||||
|
data.splice( row, 1 );
|
||||||
|
|
||||||
|
// Update the _DT_RowIndex parameter on all rows in the table
|
||||||
|
for ( var i=0, ien=data.length ; i<ien ; i++ ) {
|
||||||
|
if ( data[i].nTr !== null ) {
|
||||||
|
data[i].nTr._DT_RowIndex = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove the target row from the search array
|
||||||
|
var displayIndex = $.inArray( row, settings.aiDisplay );
|
||||||
|
settings.asDataSearch.splice( displayIndex, 1 );
|
||||||
|
|
||||||
|
// Delete from the display arrays
|
||||||
|
_fnDeleteIndex( settings.aiDisplayMaster, row );
|
||||||
|
_fnDeleteIndex( settings.aiDisplay, row );
|
||||||
|
_fnDeleteIndex( that[ thatIdx ], row, false );
|
||||||
|
|
||||||
|
// Check for an 'overflow' they case for displaying the table
|
||||||
|
_fnLengthOverflow( settings );
|
||||||
|
} );
|
||||||
|
} );
|
||||||
|
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user