Deleting query parameters when using ColumnControl
Deleting query parameters when using ColumnControl

Test Case: https://jsbin.com/bavabaq/edit?html,output
In the past, I've used
ajax.data = function (d) { delete d.columns; return d}
When I use columnControl
, I get an error. See the test case comments for
This question has an accepted answers - jump to answer
Answers
See the test case comments for the line that is causing the error:
n.page.info().serverSide && n.on("preXhr.DT", function(t, e, n) {
n.columns[i._idx].columnControl || (n.columns[i._idx].columnControl = {});
Is it possible to remove the columns query parameter from being sent to the server when using
columnControl
?According to the ColumnControl server side processing docs ColumnControl adds column search information to the
columns
object. It looks like that error probably comes from the columnControl.js include. @allan might be willing to add a check to make sure thecolumns
object exists as part of that statement and possibly in other areas of the code.Please explain why you are wanting/needing to remove the
columns
object from the server side processing data. Maybe we can provide an alternative.Kevin
One option might be to use
preXhr
to remove thecolumns
object instead ofajax.data
. Possibly it will execute after the ColumnControlpreXhr
event you show above thus eliminating the error.Kevin
Thanks!
That did not resolve the issue. I think I need to modify my server-side API to accept columns. The reason I was deleting columns is that I wanted to use a simpler server API syntax because I was also using the API for other purposes.
Probably the docs for ColumnControl should be updated. I have encountered old posts where deletion of attributes is allowed in the way I was doing it.
Hi,
You are right - I should allow for data being deleted from the submitted object, and hadn't considered that here. I've committed a fix to ColumnControl will account for that in future.
The nightly build will be up to date with the change soon, and it will be in the next release.
Allan