Why do I have to start search with capitol letter?
Why do I have to start search with capitol letter?
I am using server-side processing taken from this example: https://datatables.net/examples/data_sources/server_side.html
I want to be able to search on several words. The problem is that I have to start the search with capitol letter. I have several columns with e.g. "Terje Olsen" and "2011-666". Now I can search for "-666 terje" but returns nothing if I don't use "-666 terje" (with T). I have turned of "serverSide": true, so then I can search multiple words. But still I have to use correct letters for text. "Terje" and not "terje". Why is this
var table = $('#example').DataTable( {
language: {url: '//cdn.datatables.net/plug-ins/1.10.19/i18n/Norwegian-Bokmal.json'},
"processing": true,
// "serverSide": true,
"ajax": "/code/server_processing.php",
"columns": [
{
"className": 'details-control',
"orderable": false,
"data": null,
"defaultContent": '',
"render": function () {
return '<i class="fas fa-plus-circle" aria-hidden="true"></i>';
},
width:'10px'
},
{ "data": 1 },
{ "data": 5 },
{ "data": 9 }
],
"order": [[1, 'asc']],
"rowCallback": function( row, data, index ) {
if ( typeof data[13] !== "undefined" ) {
$(row).addClass('gul');
}
}
} );
Answers
With server side processing enabled your server script is performing the search. This is the place to look as to why its case sensitive. Maybe the function you are using for the search has an option to turn off case sensitive searches. This would be the case if you are using regex.
Kevin
Is there a better PHP script for generating the json other than the server_processing.php example? I don't understand why I can do a smart search when I turn off server_processing but does not work with server_processing: true. Where can I look to make a better filter for the PHP file that generates json? Or can I send in these parameters to the PHP file without server_processing?
These two old threads, here and here, should help and explain the logic.
Thanks but I am very confused. I am able to search on several words when I turned off processing: and serverSide: But still can not search non-case-sensitive. I have to spell the word "Terje" and not "terje". So i have progress.
I read your link to the discussion: https://datatables.net/forums/discussion/3343/server-side-processing-and-regex-search-filter/p1
but the discussion is closed and I can not find the text Allan is referring to about "filtering".
I am using the standard server_processing.php latest from GitHub.
Before I have used DataTables with php writing out the table in HTML so this is the first time I am using ajax and the json(correct?) format. Is this a bad idea? I only have 1000 records so I don't need really "server_processing" - I just use the php file to generate json. But why can't I get hits on case-insensitive search? Is there something in the ssp.class.php file that I can tweak? Or am I completely on a wrong track since I really don't need the search to be processed every time I type a search, meaning I search really on the html table.
Hi, I think I solved this. Maybe not the "correct" way? Anyway it worked when I added this "caseInsensitive": true. I found some help here: https://datatables.net/forums/discussion/46450/datatables-case-insensitive-search-issue
You can check it here: https://dev.biofokus.no/bf-prosjekter/