Dropdown filter on specific column in DataTable

Peter

I'm using DataTables to create table. One of columns contains 'i' element and hidden input. I would like to filter data rows by that hidden value, but I can't manage to do that. As far I found that problem is in search() method, I suppose it doesn't search in children elements like 'input' in which I'm keeping my value. Code fragment:

var select = $('<select><option value=""></option><option value="true">Accepted</option><option value="false">Rejected</option></select>')
                     .appendTo($(column.footer()).empty())
                                .on('change', function () {
                                    var val = $(this).val();

                                    column.search(val, true, false) // problem is here
                                        .draw(true);
                                });
Peter

Nevermind, I've managed to achieve this on my own. I needed to define "columnDefs" and inside this "targets" which are columns that you want to filter and "render". Here's the code:

var table = $('#dataCheck').DataTable({
    "sDom": "ltp",
    "columnDefs": [{
        "targets": [6],
        "render": function ( data, type, full, meta ) {
            if(type === 'filter'){
                return $('#dataCheck').DataTable().cell(meta.row, meta.col).nodes().to$().find('input').val();
            } else {
                return data;
            }
        }
    }],
    initComplete: function () {
        this.api().columns().every(function (i) {
            var column = this;
            if (i == 6)
            {

                var select = $('<select><option value="..."></option><option value="true">Accepted</option><option value="false">Rejected</option></select>')
                     .appendTo($(column.footer()).empty())
                                .on('change', function () {
                                    var val = $(this).val();

                                    column.search(val, true, false)
                                        .draw(true);
                                });

                column.data().unique().sort().each(function (d, j) {
                    select.append('<option value="' + d + '">' + d + '</option>')
                });
            }

        });
    }
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to disable a search/filter on a specific column on a datatable?

From Dev

Dropdown list is not show in primefaces datatable column filter box

From Dev

Search or filter a column in jquery datatable using multi select dropdown with checkbox

From Dev

Applying filter for column using multi select dropdown with checkbox in datatable

From Dev

DataTable with dropdown Column

From Dev

Datatable function for specific column

From Dev

DataTable need to sum a column with filter on it

From Dev

datatable column filter not showing up

From Dev

DataTable need to sum a column with filter on it

From Dev

Jquery DataTable column Filter Datepicker

From Dev

not able to filter the individual column in datatable

From Dev

Filter/subset specific column

From Dev

Filter table on specific column

From Java

Change column filter "All" label in datatable

From Dev

Primefaces - datatable column filter textbox not appearing

From Dev

Primefaces Datatable (date column) Filter by calendar

From Dev

Changing the width of column filter textbox in Datatable

From Dev

Datatable draw() method not working on column filter

From Dev

DataGridView column filter using datatable as source

From Dev

Changing the width of column filter textbox in Datatable

From Dev

Datatable draw() method not working on column filter

From Dev

how to place datatable column filter on after datatable title

From Dev

Filter Specific Column Number in Excel

From Dev

Filter a value in dropdown list with value in a column

From Dev

Factor dropdown filter in DT::datatable in shiny dashboards not working

From Dev

Add a row under specific column in datatable

From Dev

Individual column searching on specific columns, DataTable

From Dev

datatable get specific column from row

From Dev

How to populate specific DataTable column with values

Related Related

  1. 1

    How to disable a search/filter on a specific column on a datatable?

  2. 2

    Dropdown list is not show in primefaces datatable column filter box

  3. 3

    Search or filter a column in jquery datatable using multi select dropdown with checkbox

  4. 4

    Applying filter for column using multi select dropdown with checkbox in datatable

  5. 5

    DataTable with dropdown Column

  6. 6

    Datatable function for specific column

  7. 7

    DataTable need to sum a column with filter on it

  8. 8

    datatable column filter not showing up

  9. 9

    DataTable need to sum a column with filter on it

  10. 10

    Jquery DataTable column Filter Datepicker

  11. 11

    not able to filter the individual column in datatable

  12. 12

    Filter/subset specific column

  13. 13

    Filter table on specific column

  14. 14

    Change column filter "All" label in datatable

  15. 15

    Primefaces - datatable column filter textbox not appearing

  16. 16

    Primefaces Datatable (date column) Filter by calendar

  17. 17

    Changing the width of column filter textbox in Datatable

  18. 18

    Datatable draw() method not working on column filter

  19. 19

    DataGridView column filter using datatable as source

  20. 20

    Changing the width of column filter textbox in Datatable

  21. 21

    Datatable draw() method not working on column filter

  22. 22

    how to place datatable column filter on after datatable title

  23. 23

    Filter Specific Column Number in Excel

  24. 24

    Filter a value in dropdown list with value in a column

  25. 25

    Factor dropdown filter in DT::datatable in shiny dashboards not working

  26. 26

    Add a row under specific column in datatable

  27. 27

    Individual column searching on specific columns, DataTable

  28. 28

    datatable get specific column from row

  29. 29

    How to populate specific DataTable column with values

HotTag

Archive