tabletools and dom text

tabletools and dom text

ensgrpensgrp Posts: 2Questions: 0Answers: 0
edited July 2010 in General
I'm currently using tabletools to export a datatable containing regular text and some input text fields. The regular text exports fine however the input boxes are stripped from the exported data.

I added the code below to fix the sort on the dom text. If i hit the header for a column to cause a sort, that column will export fine using tabletools.
[code]
$.fn.dataTableExt.afnSortData['dom-text'] = function ( oSettings, iColumn )
{
var aData = [];
$( 'td:eq('+iColumn+') input', oSettings.oApi._fnGetTrNodes(oSettings) ).each( function () {
aData.push( this.value );
} );

return aData;
}
[/code]


Thanks,

Justin

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi Justin,

    Interesting one! What TableTools does is to simple read the internal data store that DataTables keeps of the table and outputs that (after having stripped the HTML - hence why you don't get the input tag). However, when you are using the live DOM sorting, what that is doing is to write the value of the input tag into that internal data store, which is why it works when you sort that column first.

    There isn't really a way around this at the moment I'm sorry to say - the closest would be to have TableTools sort on that column when one of it's actions is requested, then restore the sort to what it was, and finally take whatever action was needed. This would require a little hacking of the source at the moment, although will be much easier in the next revision of TableTables :-)

    Regards,
    Allan
  • ensgrpensgrp Posts: 2Questions: 0Answers: 0
    Allan,

    Thanks for your response. I decided to go with a server side function as it will handle a larger data set and not require flash support. Keep up the awesome work on Datatables.

    Thanks,

    Justin
This discussion has been closed.