Searching range of number with server side rendering

Searching range of number with server side rendering

LeNaayLeNaay Posts: 2Questions: 1Answers: 0

Hello,

First of all thanks for the great job you did with this library !

I'm actually facing a problem :

I'm using DataTable on a large set of data (200k row currently) so I use the server-side rendering. But my problem is that I want to search on a specific column with a select. This column is the status of my order and it's a numeric value : 1 for pending, 2 for received and 0 for cancel. Actually I have a select with the value of each state (see code below) but I want to have an another option with all pending and received. But because of the serverside renderring I can't perform a search with regex...

Do you have any ideas of how to make this ?

initComplete: function () {
            var column = this.api().column(8);
            var select = $('<select><option value="">All</option></select>')
                .appendTo($(column.header()))
                .on('click', function (e) {
                    e.stopPropagation();
                })
                .on('change', function () {
                    var val =  $(this).val()
                    column
                        .search(val ? val : '')
                        .draw();
                });

            select.append('<option value="2">received</option>')
            select.append('<option value="1">pending</option>')
            select.append('<option value="0">cancel</option>')
        }

PS : sorry for my poor english not my mother tongue

Answers

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

    There are a few threads, such as this one, that shows how to perform server-side regex searches - it would be worth looking at that and seeing if it nudges you in the right direction,

    Colin

  • LeNaayLeNaay Posts: 2Questions: 1Answers: 0

    Thanks a lot, I saw a lot of topics but I was looking with 'Search', and I didn't saw this one

This discussion has been closed.