TableTools and Row Data
TableTools and Row Data
eyre.michael
Posts: 21Questions: 0Answers: 0
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
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
This discussion has been closed.
Replies
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
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
Regards,
Allan