Search not working with checkbox types

Search not working with checkbox types

annekateannekate Posts: 7Questions: 3Answers: 0

Hello,

I have search filters per table and per column. The most common cell types I use are text, select, and checkbox.
Recently I realized (Jan 17) that search (on table or column) wasn't working for checkbox types.
I vividly remember this working before. I couldn't identify a specific commit that broke it either. I reset to a much older commit and it still didn't work.
Using datatables-1.13.4.

Here's how I have the column configured:

{
    'data': 'checkbox_column',
    'name': 'checkbox_column',
    'label': 'Checkbox Column',
    'className': 'editable',
    'type': 'checkbox',
    'multiple': True,
    'options': [
        {'label': 'Option 1', 'value': 'OPTION_1'},
        {'label': 'Option 2', 'value': 'OPTION_2'},
    ]
 }

Here's how I handle column search:

function setup_column_search() {
  // runs within initComplete
  this.api().columns().every(function() {
    var column = this;
    var title = column.header().textContent;

    // skip non-search fields
    if (!$(column.footer()).hasClass('non-data')) {
      var input = document.createElement('input');
      input.placeholder = title;
      column.footer().replaceChildren(input);

      input.addEventListener('keyup', function() {
        column.search(input.value).draw();
      });
    }
  });
}

Is this a known issue?
Are there other things that can break this functionality?

Thank you.

Answers

  • kthorngrenkthorngren Posts: 21,082Questions: 26Answers: 4,908
    edited January 29

    What you show above looks like an Editor field not a Datatables column. Its hard to say with just code snippets what the issue might be. Can you post a link to your page or build a simple test case that replicates the issue you are having? This will allow us to see what your checkbox looks like to offer suggestions.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    You might need to use columns.render to provide the value you want to search for based on the checkbox state. Use Orthogonal data to set the search value for the filter process. This example might help.

    Kevin

Sign In or Register to comment.