Filtering table data on a specific column when checkbox is checked

Filtering table data on a specific column when checkbox is checked

badbytebadbyte Posts: 33Questions: 7Answers: 0

I have set up a datatable of which I can search through all categories (columns). For the sake of simplicity I'll be referring to a table of DHL packages which has 3 columns:
1. DHL Number
2. Package status (sent, arrived)
3. Date of pickup

on my webpage, I have a checkbox what is supposed to filter out (hide) all packages that have arrived since we should be interested about the packages in transit. And in an unchecked state it should show all packages.
Theoretically I would do a search for "sent" when the checkbox is checked. But how do I do that as js code? What I have done till now is:

dhlList.columns(1).Search('Sent').draw();

And this is my config of that table:
dhlList = $('#dhlList').DataTable({ scrollY: '60vh', autoWidth: true, searching: false, searchable: true, 'aoColumns': [ null, null, null, { "bSortable": false }, ], 'bSortable': [ null, null, null, { "bSortable": false }, ], paging: false });

Yet I get the error message that "dhlList.columns(...).Search is not a function".
What am I missing here?

This question has accepted answers - jump to:

Answers

  • Bindrid2Bindrid2 Posts: 79Questions: 4Answers: 12
    Answer ✓

    Search is a lower case s

  • badbytebadbyte Posts: 33Questions: 7Answers: 0

    :D right

  • badbytebadbyte Posts: 33Questions: 7Answers: 0
    edited October 2018

    and how do I reverse the process? I mean make it show both sent AND arrived packages?

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947
    Answer ✓

    You can use the regex option of the search() api.

    Kevin

This discussion has been closed.