From 2be56a63fcf8c4eb44741389af2e35edfca4dfc6 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Sun, 26 May 2013 09:59:15 +0100 Subject: [PATCH] Dev: Include row details API file - Had split the row details out into its own file a little while back, since it is 100% self contained now, but hadn't committed the file! Here is it now. --- media/src/api/api.row.details.js | 151 +++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 media/src/api/api.row.details.js diff --git a/media/src/api/api.row.details.js b/media/src/api/api.row.details.js new file mode 100644 index 00000000..507a01e0 --- /dev/null +++ b/media/src/api/api.row.details.js @@ -0,0 +1,151 @@ + + +(/** @lends */function() { + +var _api = DataTable.Api; + + +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