From fddc869390d93dd949f6e2aed14a3ea44e8f2926 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Mon, 20 May 2013 08:55:42 +0100 Subject: [PATCH] API: Promote row().index() to work for plurals as well - With the new plural option for registering API methods, there is no harm in adding rows().index() to get the indexes of the selected rows. --- media/src/DataTables.js | 2 +- media/src/api/api.row.js | 207 -------------------------------------- media/src/api/api.rows.js | 57 +++++++++++ 3 files changed, 58 insertions(+), 208 deletions(-) delete mode 100644 media/src/api/api.row.js diff --git a/media/src/DataTables.js b/media/src/DataTables.js index 329c8a41..1cf010b5 100644 --- a/media/src/DataTables.js +++ b/media/src/DataTables.js @@ -115,7 +115,7 @@ require('api.ajax.js'); require('api._selectors.js'); require('api.rows.js'); - require('api.row.js'); + require('api.row.details.js'); require('api.columns.js'); require('api.cells.js'); require('api.order.js'); diff --git a/media/src/api/api.row.js b/media/src/api/api.row.js deleted file mode 100644 index 775af008..00000000 --- a/media/src/api/api.row.js +++ /dev/null @@ -1,207 +0,0 @@ - - -(/** @lends */function() { - -var _api = DataTable.Api; - - - - - -/** - * - */ -_api.register( 'row()', function ( selector, opts ) { - return _selector_first( this.rows( selector, opts ) ); -} ); - - -_api.register( 'row().data()', function ( data ) { - var ctx = this.context; - - if ( data === undefined ) { - // Get - return ctx.length && this.length ? - ctx[0].aoData[ this[0] ]._aData : - undefined; - } - - // Set - ctx[0].aoData[ this[0] ]._aData = data; - - // Automatically invalidate - _fnInvalidateRow( ctx[0], this[0], 'data' ); - - return this; -} ); - - -_api.register( 'row().index()', function () { - return this.length ? this[0] : undefined; -} ); - - - - - -(function() { - -var details_add = function ( ctx, row, data, klass ) -{ - // Convert to array of TR elements - var rows = []; - var addRow = function ( r, k ) { - if ( ! r.nodeName || r.nodeName.toUpperCase() !== 'tr' ) { - r = $('').find('td').html( r ).parent(); - } - - $('td', r).addClass( k )[0].colSpan = _fnVisbleColumns( ctx ); - rows.push( r[0] ); - }; - - if ( $.isArray( data ) || data instanceof $ ) { - for ( var i=0, ien=data.length ; i 0 ) { - // On each draw, insert the required elements into the document - table.on('draw.DT_details', function () { - table.find('tbody tr').each( function () { - // Look up the row index for each row and append open row - var rowIdx = _fnNodeToDataIndex( settings, this ); - var row = settings.aoData[ rowIdx ]; - - if ( row._detailsShow ) { - row._details.insertAfter( this ); - } - } ); - } ); - - // Column visibility change - update the colspan - table.on( 'column-visibility.DT_details', function ( e, settings, idx, vis ) { - // Update the colspan for the details rows (note, only if it already has - // a colspan) - var row, visible = _fnVisbleColumns( settings ); - - for ( var i=0, ien=settings.aoData.length ; i