Export Data returning "Undefined" Results

Export Data returning "Undefined" Results

kevinkevin Posts: 3Questions: 0Answers: 0
edited October 2011 in TableTools
Hello!

I love this tool and decided to add the TableTools plugin to the stack. I am currently using TableTools 2.0.1 and Data Tables 1.8.2.

I am currently starting with an empty table body on my html file (table headers static):

[code]


Tracking
Account Manager
Completed
Carrier Name
Premium
Mode
An. Premium



[/code]

and populating the data table with an Ajax request which returns this JSON result:

[code]
[{"TrackingNumber":"12345","Account Manager":"AM","Completed Date":"2011-08-29","Carrier Name":"Carrier","Premium":"1234","Payment Mode":"1234","Annualized Premium":"1234"},{"TrackingNumber":"6789","Account Manager":"AM","Completed Date":"2011-08-29","Carrier Name":"Carrier","Premium":"1234","Payment Mode":"1234","Annualized Premium":"1234"}]
[/code]

This is my Javascript code:

[code]
...
// data table init (in between the jQuery read function)
dataTable = $("#data-table").dataTable({
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "/js/thirdparty/datatables/tabletools/swf/copy_cvs_xls.swf"
},
"bProcessing": true,
"aoColumns": [
{"mDataProp": "TrackingNumber"},
{"mDataProp": "Account Manager"},
{"mDataProp": "Completed Date"},
{"mDataProp": "Carrier Name"},
{"mDataProp": "Premium"},
{"mDataProp": "Payment Mode"},
{"mDataProp": "Annualized Premium"}
]
});
...

// on success of Ajax call, update datatable
function updateDataTable(data){
dataTable.fnClearTable();
dataTable.fnAddData(data);
}

[/code]

This part works out perfectly; I can organize and view the data, as expected.

But when I try to export the data to any format, I get undefined fields:

[quote]
'Tracking' 'Account Manager' 'Completed' 'Carrier Name' 'Premium' 'Mode' 'An. Premium'
'undefined' 'undefined' 'undefined' 'undefined' 'undefined' 'undefined' 'undefined'
'undefined' 'undefined' 'undefined' 'undefined' 'undefined' 'undefined' 'undefined'
[/quote]

I saw the other thread where they had similar problems, but using the latest versions of DataTable and TableTools doesn't fix this problem for me. Has anyone else run into something similar to this? Thank you!

Replies

  • kevinkevin Posts: 3Questions: 0Answers: 0
    Hi Friends,

    I believed I solved the problem. Thanks for your time!
  • felixcrivfelixcriv Posts: 2Questions: 0Answers: 0
    Hi. How do you did it?. I'm dealing with the same problem.

    Thanks.
  • kevinkevin Posts: 3Questions: 0Answers: 0
    Hey Felix,

    for the most part, I couldn't get the TableTools to utilize the JSON data being returned from the Ajax request, so instead of responding with JSON data, I switch out to just responding with an array of arrays.

    Ajax response:
    [code]
    [["12345","user","2011-10-06","test","123.00","1","456.00"],["23456","user2","2011-10-03","test2","12.00","12","234.00"]
    [/code]

    Hope that helps!
  • felixcrivfelixcriv Posts: 2Questions: 0Answers: 0
    Thanks Kevin, I will try it.
  • prubinprubin Posts: 26Questions: 0Answers: 0
    I am having what I believe is the same problem. I am unable to export with ajax JSON data filling the table. Unlike Kevin, I cannot change the JSON data into array of arrays. Is this a bug or a missing configuration of some sort?
  • dvnandoverdvnandover Posts: 42Questions: 0Answers: 0
    I am facing the same problem here.
  • SchlauFuchsSchlauFuchs Posts: 1Questions: 0Answers: 0
    me, too. Datatables 1.9.3 and Tabletools 2.0.1. Data is inserted using ajax call
This discussion has been closed.