Accessing "sSearch_n" from javascript
Accessing "sSearch_n" from javascript
TheGiggler
Posts: 6Questions: 0Answers: 0
I will try to type this so it is as clear as possible what I am trying to do ...
Anyway ...
I have a grid, multi-select, multi-column filtering.
Everything works great (thank you!).
What I'm trying to do next is, when a custom button is clicked, take an array of ids that I have cobbled together from the selected rows, and the search parameters ((sSearch_0 ... sSearch_n) previously entered by the user and make an ajax request to my server side code.
Sending my array is obviously no problem but I am having some trouble finding those sSearch_n values.
I see them appended to the ajax querystring that is the original source of the grid data and assumed they were passed in the aoData, but I can't find them in there.
Could you tell me where I can grab this data from so I can append it to the ajax call I make when my button is clicked?
Thanks!
Anyway ...
I have a grid, multi-select, multi-column filtering.
Everything works great (thank you!).
What I'm trying to do next is, when a custom button is clicked, take an array of ids that I have cobbled together from the selected rows, and the search parameters ((sSearch_0 ... sSearch_n) previously entered by the user and make an ajax request to my server side code.
Sending my array is obviously no problem but I am having some trouble finding those sSearch_n values.
I see them appended to the ajax querystring that is the original source of the grid data and assumed they were passed in the aoData, but I can't find them in there.
Could you tell me where I can grab this data from so I can append it to the ajax call I make when my button is clicked?
Thanks!
This discussion has been closed.
Replies
They should be. aoData is an array of objects with name / value properties for each object, so it isn't quite as easy as checking for an object property, you need to scan over the array and check the name of each one to find what you are looking for.
Allan
(p.s. I assume we are talking about `aoData` in fnServerParams here?).
Yep, that aoData.
I'm trying to access it in fnClick of a button I 've added to "aButtons".
I guess my question is really what is the correct way to get aoData?
I tried oTable._fnServerParams() but that returns undefined. (oTable is a var that points to my table).
I saw oTable.fnSettings() used in another post.
That does return an array of objects, but they represent each row on the gird, not the sort/search/etc params that are sent with the Ajax call.
Thanks!
Yep, that aoData.
I'm trying to access it in fnClick of a button I 've added to "aButtons".
[/code]
Right, so you want to access the data object outside of fnServerParams - are you using fnServerParams at all?
You might want to take a look at the download plug-ins here: http://datatables.net/extras/tabletools/plug-ins
Allan
The link to the plug-ins had what I need!
I found this line in the code for the download button and it gets me what I need:
[code]
var oParams = this.s.dt.oApi._fnAjaxParameters( this.s.dt );
[/code]
Thanks for your (very quick!) help!