How to filter numbers on number Columns

How to filter numbers on number Columns

HeveenHeveen Posts: 5Questions: 4Answers: 0

Hello Guys

I need to filter by numbers on several columns.

As you can see from the picture above, there is a dropdown "Filter by Stage" which contain numbers from 1 to 9.

So, when I select number 2, the columns [5,6,7,8,9,10,11,12,13,14] should show number 2.

My Table:

var table = $('#example2').DataTable({
"paging": false,
"lengthChange": true,
"searching": true,
"columnDefs": [
{ "orderable": false, "targets": 1 },
{ "orderable": false, "targets": 2 },
],
});

My Filter function:
$('#filterByStage').on('change', function () {
table
.columns([5, 6, 7, 8, 9, 10, 11, 12, 13,14])
.search(this.value)
.draw();
});
The filter is not giving me any results. Infact, the filter does not find any number and return an empty data table.

So, can you help me in figuring out what should i do to filter by numbers on the numeric columns

Thanks for your help
Heveen

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @Heveen ,

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • kthorngrenkthorngren Posts: 21,299Questions: 26Answers: 4,944

    When searching multiple columns like that the search is an AND search not an OR. A search plugin would need to be created to perform an OR search.

    Kevin

This discussion has been closed.