How can I prepare a timeframe for searching
How can I prepare a timeframe for searching
mamadsoli
Posts: 15Questions: 3Answers: 0
hi
I want to have two date fields for searching...
example :
instead of this
createDate: <input type="date" name="createDate" />
I write
createDate:
<input type="date" name="createDateFrom" placeholder="Create Date From" />
<input type="date" name="createDateTo" placeholder="Create Date From" />
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
This example shows how to do with an age, so you could use that as a template.
Colin
Hi @colin
Thanks, i need server Side example .
how to send data for server
Hi @mamadsoli ,
You would add it into the
ajax.data
, then it gets sent to the server,Cheers,
Colin
excuse me but i don`t know.
Should not set data in column and search In the form below:
Can You Explain more
i can not find example
i write a code is here:
http://live.datatables.net/qadoxalu/8/edit
To send the extra parameters needed for the two dates you would use
ajax.data
as mentioned by Colin. The second example in the docs show how to add the extra search data. Your server script will then need to get these parameters and use it as part of your search query. That part is specific to what you are using for your server script.Kevin
hi @kthorngren
thankyou for your answer
you confused me the most. your example Very strange.
I just want to search for a field that is not in the list of columns.
This process should be done with the search button.
i want a example please
Sorry that was the wrong link, try this - look at the second example:
https://datatables.net/reference/option/ajax.data#Examples
I updated you example to show this:
http://live.datatables.net/qadoxalu/9/edit
I changed your
ajax
to useajax.data
like this:I also simply use
table.draw();
to perform the search.Use the browser's developer tools to see the Ajax request sent to the server. This technote will provide the steps if you need.
If you are using chrome scroll to the bottom of the
Headers
tab in the Network tools then click theRun JS
button. You will see the added parametersage_min_search
andage_max_search
.Now enter some data, for my example I entered
33
and66
as shown in the screenshot:Look at the next XHR request in the Developer Tools and you will see the filled in values being sent to the server.
This is where your server script will need to get those parameters and use them as part of your query search to fetch the desired rows.
HTH,
Kevin
@kthorngren
Thanks, i Know .
It was great and I totally understood.
And after pressing the f12 key, I saw that the information was being correctly transferred to the server.
And your explanation was clear to me.
I was also pleased with @colin answer.But I couldn't understand.
thank you very match