How can a plugin modify the ajax server params?
How can a plugin modify the ajax server params?
phazei
Posts: 3Questions: 0Answers: 0
I'm using dataTables 1.10 from the repo, 4-15
I'm trying to write a plugin that adds a dropdown with columns based on particular column options. Then whenever the data is pulled from the server, either via a filter search or reordering of the columns, I need that extra data to be sent in the data object.
I have the dropdown being created just find, but I'm not sure where to hook in to manipulate the data.
Looking through the code, I found the serverParams, but it's not documented in the 1.10 references. Is it only for compatibility? Is there a more proper place to hook into that in 1.10?
The only other think I could think of was somehow over riding the _fnAjaxParameters prototype with another function that calls it and edits it's returned data, and passes that along, which I'm not quite clear enough on the workings of js to know if it's possible or not.
I'm trying to write a plugin that adds a dropdown with columns based on particular column options. Then whenever the data is pulled from the server, either via a filter search or reordering of the columns, I need that extra data to be sent in the data object.
I have the dropdown being created just find, but I'm not sure where to hook in to manipulate the data.
Looking through the code, I found the serverParams, but it's not documented in the 1.10 references. Is it only for compatibility? Is there a more proper place to hook into that in 1.10?
The only other think I could think of was somehow over riding the _fnAjaxParameters prototype with another function that calls it and edits it's returned data, and passes that along, which I'm not quite clear enough on the workings of js to know if it's possible or not.
This discussion has been closed.
Replies
Allan
So now you can do something like:
[code]
$('#example').on('preXhr.dt', function ( e, s, d ) {
d.extra = 1;
} );
[/code]
Thanks for flagging this up!
Allan
I've been using this and it seems to be working well in Chrome, and FF. It does not work in IE8. I put an alert in, and it's never fired.
Am I missing something, or is this a bug?
Thanks
Jason
I just updated to the nightly, and it's now working in IE8.
Thanks,
Jason
Hi Jason,
Great to hear that the nightly is doing the business for you. Planning to release it as 1.10.1 next week with a few other fixes in.
Allan