ajax-datatables-rails icon indicating copy to clipboard operation
ajax-datatables-rails copied to clipboard

Smart Searching in Column search not working

Open diesl opened this issue 7 years ago • 4 comments

DataTables' Smart Searching Feature is enabled in the Global Search but it seems not to be enabled in the Column Search.

In DataTables' Non Server-Side Processing mode, Smart Search is always enabled by default.

The difference in Column and Global Search is confusing for users, because they expect the same behaviour for both searches. Unfortunately I also can not find an option to enable Smart Search manually for Columns.

Can you give any hints?

diesl avatar Dec 18 '17 18:12 diesl

Why did you close this issue as invalid?

I think this issue is legitimate, because DataTables uses SmartSearch in Columns as default, while ajax-datatables-rails does not. In my opinion, they should behave the same.

diesl avatar May 06 '18 08:05 diesl

I think this issue is legitimate, because DataTables uses SmartSearch in Columns as default, while ajax-datatables-rails does not. In my opinion, they should behave the same.

I don't know how it's related to this gem.

n-rodriguez avatar May 07 '18 21:05 n-rodriguez

I don't know how it's related to this gem.

Because the Gem does create the SQL query that fetches the data according to the search terms.

So basically the smart search does split the input using the global_search_delimiter and then performs a search with each of the splitted terms. The only difference is that a smart column search is just for the particular column, whereas global smart search has to performed for every column marked as searchable, obviously. The global search works as expected, just the column search takes the whole string as search term.

To sum it up:

# Current implementation:
... WHERE column LIKE '%term1 term2%'

# Smart search: 
... WHERE column LIKE '%term1%' AND column LIKE '%term2%'

I hope I could make things more clear.

diesl avatar May 08 '18 06:05 diesl

I hope I could make things more clear.

Yes, thank you!

n-rodriguez avatar May 09 '18 00:05 n-rodriguez