Datatables Filter on first 4 columns

Datatables Filter on first 4 columns

alpalp Posts: 4Questions: 2Answers: 0

I have no experience with JS so please use small words!

I look at filter api, but my js skills are poor.

I want to filter the Datatable based on the first 1-4 invisible columns. (col1=?) AND (col2=?)... So could be just 1st col, could be all 4.

I would like to apply each filter request on button click event.

Could someone point me in right direction?

Also how to remove a filter?

thank you in advance for your help for my very noob questions.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,300Questions: 26Answers: 4,769
    Answer ✓

    I want to filter the Datatable based on the first 1-4 invisible columns. (col1=?) AND (col2=?)... So could be just 1st col, could be all 4.

    The column().search() API is used to search the table on a column by column basis. You could use columns().search() to search multiple columns for the same search term. Column numbers start counting from 0. The first column is 0.

    I would like to apply each filter request on button click event.
    Could someone point me in right direction?

    Here is a simple example searching a hidden column via a button:
    http://live.datatables.net/wuhelusa/1/edit

    Also how to remove a filter?

    See the same example. Use an empty string, ie "", to clear the search.

    Kevin

  • alpalp Posts: 4Questions: 2Answers: 0

    Thank you! For Multi this work very nice:

    table.column(0).search('tiger');
    table.column(1).search('sys');
    table.column(2).search('');
    table.column(3).search('').draw();

This discussion has been closed.