filtering on blank value filtering on blank value

good day, i am using, true, false ).order( [[ 1, 'asc' ]] ).draw();
and in my column i have blank values and some strings. Could you recomend me how can i receive rows with blank values? Reason, when i send to value blank string, i am getting whole list, like unfiltered, but i wanna to have list where cells is blank... Do someone has ideas?


  • Tester2017Tester2017 Posts: 143Questions: 22Answers: 17
    edited October 2017

    Maybe this might give you some suggestions?

    In the examples, you can check for blank.

  • allanallan Posts: 52,157Questions: 1Answers: 7,937 Site admin

    The filter() method doesn't actually change what is shown in the table is the thing, it filters the result set from an API call.

    column().search() will change what is shown in the table, and you could use a regex to get only blank values:

    table.column(0).search( '^$', true, false );


  • Posts: 3Questions: 2Answers: 0

    column(0).search("", true, false ).order( 'desc' ).draw();
    column(0).search('^$', true, false ).order( 'desc' ).draw();

    providing exactly same result

    if u have some idea, lease tell me

  • allanallan Posts: 52,157Questions: 1Answers: 7,937 Site admin

    I'd need a link to a test case showing the issue please. The example I linked to above appears to show it working.


  • AashutoshAashutosh Posts: 1Questions: 0Answers: 0
     initComplete: function () {
                this.api().columns('.colFilter').every(function () {
                    var column = this;
                    var select = $('<select class="form-control input-sm"><option value="">Select</option></select>')
                        .on('change', function () {
                            var val = $(this).val();
                            if (val === "\\(Blank\\)")
                                    .search('^$', true, false)
                                .search(val ? '^' + val + '$' : '', true, false)
           (d, j) {
                        if (d === '')
                        select.append('<option value="' + d + '">' + d + '</option>')
  • kthorngrenkthorngren Posts: 9,690Questions: 25Answers: 2,231
    edited December 2019

    As Allan asked we need a running test case that shows the problem to help debug. this way we can see your data and the behavior of your code.

    The place to start is to make sure if (val === "\\(Blank\\)") is correct. You can put a console.log statement inside to make sure .search('^$', true, false) is executing when you select (blank). I think the backslashes are causing the if statement to always be false. Its not a regex so they aren't needed to escape the parenthesis.


Sign In or Register to comment.