_fnAjaxParameters( oSettings ) returns empty search field for Date
_fnAjaxParameters( oSettings ) returns empty search field for Date
dharmeshpatel82
Posts: 15Questions: 2Answers: 0
I am using Datatable 1.9.4, I am trying to get all search field values with table properties, I am getting success but only thing is Date Search field is returning empty string in aoData variable. Can Somebody help me how to fix this?
My Code to get aoData is :
var dTable = $('#dynTable').dataTable();
var oSettings = dTable.fnSettings();
var aoData = dTable._fnAjaxParameters(oSettings);
Thank you.
This discussion has been closed.
Answers
What data search field?
Also, you are using a private API method there - I would very much suggest against that. It isn't supported.
1.10 does have a public API method for this -
ajax.params()
.Allan
Hello Allan,
I am not sure how I can Identify whether this is a Private method, My understanding that I can use it for Other Field Like
text
type Search field returns value, but onlyrange type values
are blank, In my case I am looking fordate-range
.I got this method reference on internet that I can use to directly to get all Table properties.
Can we achieve it in DataTable version 1.9.4 as for some dependencies with other project I have to use DataTable 1.9.4 in my project, instead of Latest version.
Please tell me the way I can get all properties of table including search fields (ANY TYPE of SEARCH FIELDS)
Thank you Allan.
It isn't documented :-). The leading underscore also indicates that it is private. The public APIs for Editor and DataTables are documented in the respective reference sections on their sites.
The fnServerParams method provides the option of getting that data at the time of the Ajax request. There is no public API in 1.9.4 to request that data at any time.
There is on;y one built in search field - the global search. The column filter information entered via the API is available in the submitted parameters.
Allan
Allan, So do your mean to say, There is no way we can get Date-Range type search value using DataTable Object in DataTable 1.9.4?
Actually I can not upgrade at this moment but I need to resolve my project issue, Can you suggest how I can get this value by using Table object. Any work around?
Thank you.
Can you link me to the page you are working on so I can take a look and understand the issue. Can you also state if you are trying to access this data on the client-side (and if so, at what point), or on the server-side? Currently these things aren't clear to me.
Thanks,
Allan
Hello Allan,
I am working on an Internal Website thats why I can not link you with that, but I can try explaining little bit more in detail.
I am trying to get Data from Server-side. I have Defined a Datatable with Dynamically linked with Server-Side Data and It is changing on JQuery Tab Selection. For each tab there is different data will be shown on DataTable, but I am trying to preserve filters applied on default DataTable. I am not able to get Range type filter for next DataTable re-load.
I hope I explains my scenario, Let me know if you have any question. Thank you.
So you want to change the data sent to the server on each tab change? The best way would probably be to use
ajax.url()
to change the url - event if you just change a GET parameter to identify the tab. In 1.9.4 you could try to use the oldfnReloadAjax
plug-in to change the url: http://datatables.net/plug-ins/api/fnReloadAjax .Allan
hi allan & dharmeshpatel82
could you find a solution for this issue? i have an issue i think it is related to this one.
Please advise on this:
i have in my code a filter, its type is date-range. When i want to get the value that was entered in each search filed or filter ie. parameter of datatable i am using ajax.params(). it works very well for all parameters, except the date-range.
this date-range works fine, but if i want to get the value of it by using ajax.params(), it is empty.
what i want to do is, to get all of the datatable parameters to use it in another function
thank
I figured a solution to get the value of the range date filter. But I think it is not the right way to do. However, I will explain how I did, it may help the others:
I used a selector by id for selecting the date-range filter. Then I get the value of it, and I assigned it to a new variable.
I need to get 2 values: from date and to date, and I have to separate them with "~"
var from_date_parameter = $('#datatable_range_from').val();
var to_date_parameter = $('#datatable_range_to').val();
var full_date_parameter = from_date_parameter.concat("~",from_date_parameter);
To get all parameters, I will use ajax.params(); (but with this function the date range filter will be empty).
Now to get all paramters I need to use both the returned value from ajax.params() and full_date_parameter.