column.search vs columns.search

column.search vs columns.search

joed67joed67 Posts: 14Questions: 6Answers: 1

I'm looking at the docs and sometimes I see table.column(columnNo).search(input) and other times I see table.columns(columnNo).search(input).

I'm using DataTables in Typescript (not sure if it matters) and using the singular "column" gives "Expected 0 arguments" but got 1.

If I look at the manual page:

https://datatables.net/reference/api/search()

In the Description, it says "for example table.column(0).search('Fred').draw()" using the singular "column" but this gives the above error for me.

Below on that same page, in the first example, it uses "table.columns(3).search(this.value).draw()" using the plural "columns".

In the page:

https://datatables.net/reference/api/columns()

it says "While column() provides access to a single column, this columns() method is used to allow multiple columns to be manipulated or modified at the same time."

But "search" appears to allow no arguments for column(), where it does allow arguments for columns().

Is this a Typescript thing? It had me really confused until I gave columns() a try and it worked.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,726Questions: 1Answers: 10,110 Site admin
    Answer ✓
    table.columns(columnNo).search(input).
    

    is unlikely to be what you want. It will apply the search term input to all columns that match the columnNo selector. If it is selecting just one column, then fair enough, but if it is selecting multiple columns it will apply the same search term to all matching columns (not just a group but ColA = Search && ColB = Search... etc).

    But "search" appears to allow no arguments for column(), where it does allow arguments for columns().

    Sounds like an error in our TypeScript file. As you'll be able to see in the column().search() documentation it should allow arguments.

    I've just committed a fix for this and it will be included in the typing file for DataTables 1.12 which I hope will drop next week.

    Regards,
    Allan

Sign In or Register to comment.