Yogesh
Yogesh

Reputation: 924

jQuery datatable search functionality in Server Side Processing

In jQuery Datatable I am fetching data using Ajax i.e. Server Side Processing.

Situation : If I type a text in search input field it will send a request to server side script to fetch the data to match the data with the text typed in search field

This is working correctly.

Now if I pressed Space button, and added some more text in whatever already typed in search field, it will again send a request to server side script and to fetch the records matching with whole text typed in search field.

I want to implement: As in simple datatable (only intialization of datatable() function) if User type something in search field it will filter the records and if User adds some more text by adding space in search field, it will search on the subset which is returned by first search call.

Example : First I typed text as 1.8, then it will give records matching to 1.8 now if I continue typing in search field and firefox i.e. text in input field will be 1.8 firefox it will give me the records which has 1.8 and firefox in its column

Can we implement this type of functionality with Server side processing i.e. if user enters a text in search field with space then it should apply search on subset returned by earlier search.

Is it possible with built-in functions/setting/options of jQuery datatable.

Upvotes: 1

Views: 1256

Answers (1)

Yogesh
Yogesh

Reputation: 924

We need to make changes in the server script where it generates the where clause.

I have used explode function of PHP to create an array from the search string and then used this array in loop to generate a correct where clause by adding AND & OR conditions,

Upvotes: 0

Related Questions