Per-Column searching not working

Per-Column searching not working

reastwoodreastwood Posts: 3Questions: 0Answers: 0
edited July 2014 in Free community support

Hello!
I've hit an issue with trying to search on a per column basis. I am using code based on the example here:
https://datatables.net/reference/api/column%28%29.search%28%29

I'm using this to load the table

$('table.dataTables').dataTable({
                ajax: "url/blah/somedata.json",
                ordering:  false,
                columns: [
                    { data: 'client' },
                    { data: 'config' },
                    { data: 'code' },
                    { data: 'vouchernumber' }
                ],
            });

The table loads fine.

Then to test the searching i'm just using a button for now, the idea being it looks in the config column for the value of 60.

$("#test").click(function(){
                $('table.dataTables').column(1).search("60").draw();
});

However, I get an error when the button is hit:
$(...).column is not a function

Any ideas much appreciated!!

Rob

Replies

  • reastwoodreastwood Posts: 3Questions: 0Answers: 0

    Forget it, me being stupid. Had to call datatables on the table again:

    $('table.dataTables').DataTable().column(1).search("60").draw();
    
  • allanallan Posts: 63,552Questions: 1Answers: 10,476 Site admin

    There is a difference between $().dataTable() and $().DataTable(). See the FAQ.

    Allan

  • reastwoodreastwood Posts: 3Questions: 0Answers: 0

    Cheers!

This discussion has been closed.