dataTables (jquery) search by two columns

2019-09-02 04:45发布

问题:

I want to search table by only two columns. E.g. Initial search searches in all columns, I just want to search by two columns. When I use following code:

dataTable.columns([1,7])
    .search("some string")
    .draw(); 

the search text must be present in both columns to be displayed. I want to display it even if it exists in one of the columns. Can anyone help?

Thanks

回答1:

SOLVED

I've changed searching to initial which searches all columns:

dataTable
    .search(this.value)
    .draw();

And set columns which I don't want to be search in initTable:

    "columnDefs": [
    {
        "targets": [2,5],
        "searchable": false
    }]