How to filter one column with datatable?

How to filter one column with datatable?

lutfi489lutfi489 Posts: 3Questions: 1Answers: 0

I want to add a filter to only one column.
The script that I made is here.
I want to filter the status column with a dropdown, where the status is "Done", "Rejected", "In Progress".
The data that appears is based on the status selected in the dropdown.

This question has an accepted answers - jump to answer

Answers

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

    Hi @lutfi489 ,

    This example looks like what you're after,

    Cheers,

    Colin

  • lutfi489lutfi489 Posts: 3Questions: 1Answers: 0

    Hi @colin,
    For the example that you gave me I tried, but it displays a lot of input dropdowns. What if I only want to display one column dropdown?

  • lutfi489lutfi489 Posts: 3Questions: 1Answers: 0
    edited October 2019

    I use this script:
    $(document).ready(function() {
    $('#example').DataTable({
    filterDropDown: {
    columns: [
    idx: 5
    ]
    }
    } );
    } );

    but it doesn't work

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

    filterDropDown isn't anything we support. You would just modify that example I posted above, and the simplest change would be instead of

                this.api().columns().every( function () {
    

    change it to be

                this.api().columns( 5 ).every( function () {
    

    Colin

This discussion has been closed.