Please pass the search[caseInsensitive] over to the server-side processing
Please pass the search[caseInsensitive] over to the server-side processing
Hello-
I am using DataTables via shiny. The tables look nice, work quickly and are easy to setup and use, thanks! Sadly, the people at shiny say they are unable to provide case-insensitive searching, rendering the tables pretty much useless.
Here is what shiny had to say:
"I cannot do much on shiny's side unless DataTables passes the info search[caseInsensitive] over to the server-side processing: https://datatables.net/manual/server-side Currently it only passes search[value] and search[regex]."
Are there any work arounds for this, aside from making everything in my tables lower case?
Thanks so much,
Summer
Answers
Can you not just modify the Shiny code to make all searches case insensitive? In Postgres you would use
ILIKE
rather thanLIKE
for example.Allan
I'm the author of Shiny who is in charge of the DataTables integration. I can certainly make search case-insensitive in Shiny by hard-coding the value of this parameter, but it is just a bad idea: what if the user wants case-sensitive searching? Then there is no way back. By comparison, the current case-sensitive searching in Shiny can be made case-insensitive by using regular expressions, e.g. a search string [Aa][Bb][Cc], although it is very awkward.
I do not see why the server-side processing should not pass search[caseInsensitive] along with search[value] and search[regex]. The server needs to know this piece of information to decide whether the searching should be case-insensitive or not.
I agree! These are two great tools, and a very commonly used and necessary feature for both. It would be great to get it working!
Thanks for the feedback.
Interestingly this is the first time I've seen a request for this specific information to be sent to the server. So its not something I'm going to put into the DataTables core at the moment, but I would invite anyone else interested in this to also post a comment here supporting the addition of this information.
Indeed, the most common request I've about about this area of the code is to reduce the information being sent to the server for the columns (i.e. remove the regex flag). This is partly because of the default use of
GET
(I should have used defaultPOST
, but can't change it now!).in the mean time, if you do require this information you could use
ajax.data
to modify the data being sent to the server and and add information about the case sensitivity.Regards,
Allan
Thanks for the pointer to ajax.data, and I have got a workaround for this issue now. While I was working on this, I have got a new issue: I cannot find bCaseSensitive from DT.settings(), so it is not possible to dynamically read the setting. This is not a big issue, though.
Yay! Thanks to you both!