Filtering table data on a specific column when checkbox is checked

Filtering table data on a specific column when checkbox is checked

badbytebadbyte Posts: 14Questions: 2Answers: 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: 70Questions: 0Answers: 12
    Answer ✓

    Search is a lower case s

  • badbytebadbyte Posts: 14Questions: 2Answers: 0

    :D right

  • badbytebadbyte Posts: 14Questions: 2Answers: 0
    edited October 17

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

  • kthorngrenkthorngren Posts: 3,946Questions: 19Answers: 871
    Answer ✓

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

    Kevin

Sign In or Register to comment.