Custom search filter

Custom search filter

nicontrolsnicontrols Posts: 32Questions: 16Answers: 1

I've added the following code before $(document).ready:

$.fn.dataTable.ext.search.push(
    function( settings, searchData, index, rowData, counter ) {
        return false;
    }
);

I don't see any errors in the console log, but it has no affect on the table whatsoever, I was expecting my table to show zero results.

I can't seem to get $.fn.dataTable.ext.search.push to do anything at all...

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,211Questions: 26Answers: 4,928

    It works here:
    http://live.datatables.net/rahayoni/1/edit

    Maybe you can update my example to replicate your issue.

    Kevin

  • rf1234rf1234 Posts: 2,955Questions: 87Answers: 416

    I use this stuff all the time and it works. I guess you need to put it on top of your table definition but after $(document).ready.

    Have you tried that?

  • nicontrolsnicontrols Posts: 32Questions: 16Answers: 1

    I’ve tried adding it within the document ready without any luck. I see the example provided works just how I want mine too.

    Is it possible that because my data table gets its data server side it ignores the custom filter?

  • rf1234rf1234 Posts: 2,955Questions: 87Answers: 416

    I am pretty sure that this is true!

    All filtering is done on the server for server side. Why don't you turn off server side for a moment and figure it out?

    Or maybe this is a complete misunderstanding?
    When I speak about "server side" I mean the Editor mode "server side". As opposed to not having Editor "server side" turned on. Either way: The data come from the server. I think you need to turn Editor "server side" off and then it should work. just give it a try.

  • kthorngrenkthorngren Posts: 21,211Questions: 26Answers: 4,928
    Answer ✓

    The search plugin is a client side search mechanism.

    Not sure exactly what you want to do but maybe the ajax.data option can help. Haven't tested this but maybe you can send a boolean value to the server script indicting whether to run normally or to return 0 rows and indicate recordsFiltered of 0 and recordsTotal would be the normal total records.

    Kevin

This discussion has been closed.