Export Data returning "Undefined" Results
Export Data returning "Undefined" Results
kevin
Posts: 3Questions: 0Answers: 0
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!
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!
This discussion has been closed.
Replies
I believed I solved the problem. Thanks for your time!
Thanks.
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!