Strange issue with specific numbers search...
Strange issue with specific numbers search...
Hello,
a simple table with 5 columns
Checkbox | Number | Number | Filename | a href
eg. put in the columns numbers from 780 to 900
if you search for 789 and 890 the search fails and nothing happens.
So, there could be something wrong with the search logic (consecutive numbers? 123... 3456... 567... ? )
Please, could you test and fix it?
It happens on the bootstrap 4 version, downloaded from the wizard.
Here's my code now
var table = $('#mytable').DataTable( {
pageLength : 5,
lengthMenu: [[5, 10, 20, 25, 50, -1], [5, 10, 20, 25, 50, "Alles"]],
"language": {
"url": "assets/DataTables/German.json"
},
columnDefs: [
{ targets: [0, 4], "searchable": false},
{ targets: [0, 4], "orderable": false},
{ "type": "num", targets: [1, 2, 3] }
]
} )
Replies
I also tried with html instead of num and does the same.
It works for other numbers, it doesn't work for those kind of numbers only.
Thank you
Are you typing this into the default search box
789 and 890
?Sorry its not clear what this means.
Can you put together a simple test case replicating the issue with the steps needed to show the issue?
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
I can confirm...
I put inside even 234 and it fails.
Sorry its still not clear what could be wrong. Searching for number sin Datatables works, you can try this example:
https://datatables.net/examples/basic_init/zero_configuration.html
It maybe that I don't understand your data structure. You mention consecutive numbers. Does this mean that you are putting consecutive numbers in one cell?
Again please put together is simple example representing your data so we can help.
Kevin
Are you typing this into the default search box 789 and 890?
I write 789 OR 890, one at a time...obviously
I mean that it fails with numbers like that
eg. if you write
234
345
789
890...
probably there's something wrong when the numbers are consecutive, even if that's weird. What may be the cause?
Here the fiddle which shows you a simple table where it just doesn't work
https://jsfiddle.net/20tpf41k/5/
So, if you put five elements per page, and search for 789, it just fails.
well, I was able to let it run here https://jsfiddle.net/20tpf41k/5/ as you can see.
Please, now search for 789 and you can see it failing...
so, is there something into the html table declaration which does conflict or is datatables failing on its own about the search? But, why it happens just with those numbers and not with others? A mistery.
Hello, i found the conflict with
bootstrap.min.js from Bootstrap v4.1.3
if you exclude it, indeed, then the datatables works as usual.and 789 (example) is not an issue anymore
So, how to fix it, please?
Thank you
Even if
Step 1. Choose a styling framework DataTables
Step 2. Select packages DataTables
so, all DataTables...no Bootstrap reference at all,
it does conflict with the bootstrap.min.js and you can't search for those numbers because it does nothing, no errors, no filter, nothing on screen...so in this example you type 789 and it doesn't work
Thanks for the example, it is very helpful to understand the issue. I don't think it has to do with using Bootstrap. What you are seeing is normal default behavior of Datatables search.
Here is the data in your table:
When doing the default search of 789 Datatables will match all rows since 789 is in all the rows. It is found in IT01234567890_783.xml in all rows. The same behavior can bee seen in the regex search example:
https://datatables.net/examples/api/regex.html
Use the Global Search and leave the search default settings of
Treat as regex
unchecked andUse smart search
checked. Enter47
into the Global Search and there will be 4 rows with age 47 displayed and another row where$470,600
is also matched. Similar to what you are seeing in your table.If you just want the age 47 then you will need to use regex searching by checking the
Treat as regex
option and uncheckingUse smart search
. In the Global Search input type the regex expression\D47\D
. You will see only the rows with age 47 appear.You could use a regex search to get just the last row when searching for 789, for example:
This can be seen in the updated example here:
https://jsfiddle.net/20tpf41k/5/
You may need to create a new search input for the
Ordine n.
andFattura n.
columns to use the regex while using the default search for the other columns.Kevin
yes, you're right...indeed i forgot this and i was about to write here but you preceded me.
But, while those strings/numbers are there, at the same time
there is the option
{ targets: [0, 4], "searchable": false}
or I didn't understand how it works or please explain why it doesn't exclude that column from the search.
I know that there is IT01234567890 but at the same time i tried to exclude that column from the search, precisely because I don't need it.
Instead, this means that it's included. Please, how to exclude a column from the search?
The columns start counting at 0. You have 5 columns in your table. With
targets: [0, 4]
you are excluding the first column and the last. TheIT01234567890
values are in the forth column but it is referenced as column(3). You will wanttargets: [0, 3, 4]
.Kevin
sorry, i was wrong
{ targets: [0, 3, 4], "searchable": false}
nevermind
thanks
No problem. Glad we worked it out
Kevin