TableTools and Row Data

TableTools and Row Data

eyre.michaeleyre.michael Posts: 21Questions: 0Answers: 0
edited June 2011 in General
Hello,

I have been loving DataTables, and I am working on using the TableTools extra. I have been working on extending the CSV to create a pipe-delimited file and then I want to do some processing in the database after the file is created.

I have successfully created a pipe-delimited file, and get the number of selected TRs, but I am trying to get the data that is in the row, so I can do some processing on it.

This is what I have right now:
[code]

{
sExtends: "csv",
sFieldSeperator: "|",
sButtonText: "Pipe Delimited",
bSelectedOnly: true,
"fnComplete": function ( nButton, oConfig, oFlash, sFlash ) {
var selectedTRs = this.fnGetSelected(oConfig);
alert ('Number of Rows: ' + selectedTRs.length);
var aPos = this.fnGetPosition ( selectedTRs[0]);
alert ('Position = ' + aPos);
var aData = this.fnGetData ( aPos[0] );
alert ('Data: ' + aData);
}
},
[/code]

I get the alert for the number of selected rows, but I do not get any of the other alerts. I am assuming that there is an error on the rest of the code, but I am not getting any error messages in Chrome. What do I need to do to get the data? I have been able to get a string of the data, but it is not in a user friendly format. I have used the fnGetData function in other datatables, but something does not seem to be working within the tabletools.

Once I can display the data, I am sure that I can create an array of values that I can use later.

Thanks

Mike

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Hi Mike,

    I'd suggest that you want to override the fnClick functionality of the button if you want to post-process the data. Here is how TableTools does the csv click: https://github.com/DataTables/TableTools/blob/master/media/js/TableTools.js#L2133 . Note also that if you what a pipe separator you can just override sFieldSeperator as "|".

    Regards,
    Allan
  • eyre.michaeleyre.michael Posts: 21Questions: 0Answers: 0
    Thanks for getting back to me.

    It is strange that when I try to put an alert message in the fnClick, it will not export the data.

    I want to display the data before I proceed into my post-processing so I make sure of the format.
    Exporting and Displaying seems to work when using the fnComplete function, but not when putting things in the fnClick function.

    Any thoughts?
    Mike
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    I vaguely remember seeing something like that before - alert() would break the Javascript / Flash bridge or something. I'd suggest just using console.log() and looking at the console in your browser (most of them offer that now-a-days). I think you do want to use the fnClick since DataTables is expecting the export to happen there, and fnComplete is really just for letting the user know that something has happened (once the click has completed).

    Regards,
    Allan
This discussion has been closed.