Searching columns doesn't search for partial string matches

Issue #38 closed
Former user created an issue

By default datatables has an 'advanced' search where you can search for partial string matches. I've noticed that it doesn't really work when using this library.

Is there a way to enable partial string searches?

Example:

Currently, if i search for "text" in ["example text"] it would yield no results but searching for "examp" would.

Could this be related to the filter_queryset(), specifically where you use 'istartwith' instead of 'icontains' ?

Comments (4)

  1. Maciej Wisniowski repo owner

    As you've noted it is a matter of istartswith. You can simply override filter_queryset() method in your descendant class and use icontains or anything you need.

  2. Ryan Meagher

    If i wanted to disable the search functionally provided by filter_queryset() and use the one provided by the datatables library, would that be difficult to do?

  3. Maciej Wisniowski repo owner

    You have to differentiate between server side and the client side. DataTables filtering is done in the browser (client side) so in order to do it, you need all the data loaded previously. If you're using server side processing then you have to handle filtering separately from DataTables - on the server.

  4. Log in to comment