jbox-web / ajax-datatables-rails

A wrapper around DataTable's ajax methods that allow synchronization with server-side pagination in a Rails app
MIT License
587 stars 228 forks source link

Possibility to change operator from AND to OR #403

Closed mrudult closed 2 years ago

mrudult commented 2 years ago

I have got a table where the filters need be joined by OR instead of AND

Is there a way we can change this to accept :or?

n-rodriguez commented 2 years ago

Is there a way we can change this to accept :or?

Yes, just override the existing method :

class MyDatatable < AjaxDatatablesRails::ActiveRecord
  def build_conditions_for_selected_columns
    search_columns.map(&:search_query).compact.reduce(:or)
  end
end
mrudult commented 2 years ago

@n-rodriguez Thanks. It worked.