fnAddTrAndDisplay

fnAddTrAndDisplay

OBCENEIKONOBCENEIKON Posts: 9Questions: 0Answers: 0
edited January 2014 in Plug-ins
Posting in case anyone can use, I combined the fnAddTr and the fnAddDataAndDisplay plugins.
Take a TR element and add it to a DataTables table and display it on the screen by jumping the pagination to the required location. This function also returns an object with the added TR element and it's index in aoData such that you could provide an effect (fade for example) to show which row has been added. This function will only take a 1D object, and not a 2D array (i.e. it will not add multiple rows like fnAddData). Useful for maintaining custom classes and other attributes.

[code]
$.fn.dataTableExt.oApi.fnAddTrAndDisplay = function(oSettings, nTr) {
var nTds = nTr.getElementsByTagName('td');
if ( nTds.length != oSettings.aoColumns.length )
{
alert( 'Warning: not adding new TR - columns and TD elements must match' );
return;
}

var aData = [];
var aInvisible = [];
for ( var i=0 ; i

Replies

  • allanallan Posts: 57,686Questions: 1Answers: 9,195 Site admin
    Very cool - thanks for sharing with us!

    Allan
This discussion has been closed.