Access custom param using 'download' plugin

Access custom param using 'download' plugin

wenyiwuwenyiwu Posts: 9Questions: 0Answers: 0
edited November 2011 in TableTools
Hi, I'm using the 'download' plugin for TableTools. It sends the whole set of params that datatable sends to server processing, but I'm having trouble finding the custom params that I push to aoData from the server side. Below is my datatable initialization code.

[code]

var rptTable = $('#tblReport').dataTable({
"bProcessing": true,
"bServerSide": true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"sDom": 'lfrtip<"clear spacer">T',
"oTableTools": {
"sSwfPath": "../Scripts/copy_cvs_xls_pdf.swf",
"aButtons": [{
"sExtends": "download",
"sButtonText": "CSV",
"sButtonClass": "DTTT_button_csv",
"sButtonClassHover": "DTTT_button_csv_hover",
"sUrl": "Utility/GenerateCSV.aspx"
}]
},
"aaSorting": [[1, "asc"]],
"sAjaxSource": "Services/Data.svc/GetData",
"fnServerData": function (sSource, aoData, fnCallback) {
/* Add some data to send to the source */
aoData.push({ "name": "sSMID", "value": smId });
$.ajax({
dataType: "json",
type: "GET",
contentType: 'application/json',
url: sSource,
data: aoData,
success: function (msg) {
debugger;
$('#pnlView').show();
var json = $.evalJSON(msg.d); //JSON.parse(msg.d);
fnCallback(json);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
debugger;
alert(XMLHttpRequest.statusText);
var errorMessage = JSON.parse(XMLHttpRequest.responseText);

alert(errorMessage.Message);
}
});
}
});
[/code]

In other words, I want to know how I can find the param I added through this line
[code] aoData.push({ "name": "sSMID", "value": smId });[/code]
in Utility/GenerateCSV.aspx, the page that's responsible to generate the csv file.

Thank you so much! Pls let me know if my question is not clear.

--Wenyi

Replies

  • wenyiwuwenyiwu Posts: 9Questions: 0Answers: 0
    edited November 2011
    Allan or somebody, please help me out :) thx in advance!
  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin
    If you use fnServerParams to add your data then I believe that this should work (although I've not tested it). fnServerParams was introduced in 1.8.2 to make sending extra parameters to the server easier. Otherwise then a small modification will be needed to the download plugin for TableTools to add your parameter.

    Allan
  • wenyiwuwenyiwu Posts: 9Questions: 0Answers: 0
    Sorry Allan fnServerParams didn't work...I ended up passing the param as query string...i also modified the 'download' plugin so the "?" in the query string is a "?" or "&" depending on the situation. Thanks! Keep up all the great work!
This discussion has been closed.