How do I post column sort data in tabletools?
How do I post column sort data in tabletools?
crunchfactory
Posts: 29Questions: 8Answers: 2
How do we post column sort data in tabletools, in this case, so we can mirror tablesorting in the table instance on our post of data to make into a csv, I thought it would be something like the bottom 2?
var oParams = this.s.dt.oApi._fnAjaxParameters( this.s.dt );
var aoPost = [
{ "name": "action", "value": "csv" },
{ "name": "csvQuery", "value": table.ajax.params().search.value },
{ "name": "csvColumn", "value": table.ajax.params().order[i].column },
{ "name": "csvColDir", "value": table.ajax.params().order[i].dir }
];
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Hi,
I've just sent you a PM about this, but for anyone else reading, the problem with the above is the
order[i]
- in this case thei
is undefined. You could replace it with0
to get the first sorting column data, but it might be easiest to useJSON.stringify( table.ajax.params().order )
and then decode the array of objects as JSON at the server. Indeed, you could doJSON.stringify( table.ajax.params() )
and have everything from the last server-side processing request available at the server without needing to add each manually.Regards,
Allan
Beautiful, and thank you;
JSON.stringify( table.ajax.params().order )
I guess my surprise is that "table.ajax.params().order" was one of the first thing I tried, but it takes JSON.stringify to return the properties ans values?
If you were to just use the
order
parameter, the client would simply be sending[object Object]
to the server, as that is thetoString()
result of an array (since HTTP parameters are basically strings, the browser will get the string value of an object as the value to send). So you need to JSONify the object, or post the values individually.Regards,
Allan