Creating a custom function - date ranger

Creating a custom function - date ranger

meetinmeetin Posts: 4Questions: 3Answers: 0
edited February 2015 in Free community support

Hello,

I'm quite new to this library and I have some problems.

My goal is to programmatically call search by using custom filter function. The problem with examples like this one: https://datatables.net/examples/plug-ins/range_filtering.html is that it works when using default search functionality.

What I want to do is something like this (from button outside the datatables):

$('button').on('click', function(){
   var from, to;
   table.customSearch(from, to).draw() 
}) 

Now I want customSearch to be something like if(is in range) return true, else return false. Basically how the example(https://datatables.net/examples/plug-ins/range_filtering.html) works.

Is it possible to do something like $.fn.dataTable.ext.customSearch() so it can be called globally by the dataTables object?

Answers

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin

    If you want to create an API plug-in (which the code above suggests) to control your search plug-in the guide is here. However, $.fn.dataTable.ext.customSearch() is not something DataTables will look for by itself. If you want a custom filtering function, you would use $.fn.dataTable.ext.search as shown in the example you linked to.

    Allan

This discussion has been closed.