Skip to content

Allow again overriding filter_records, sort_records... #228

@panmari

Description

@panmari

Currently, when overriding for example filter_records in a custom datatable, it's ignored due to 'load_orm_extension' being called on initialize, which overrides the custom method by the one provided in the orm.

def initialize(view, options = {})
  @view    = view
  @options = options
  load_orm_extension
end

According to the rails generator datatable template, such use should be possible:

  # ==== These methods represent the basic operations to perform on records
  # and feel free to override them

  # def filter_records(records)
  # end

  # def sort_records(records)
  # end

  # def paginate_records(records)
  # end

As a workaround I'm currently overriding retrieve_records in my custom datatable

  def retrieve_records
    records = fetch_records
    records = filter_records_with_my_awesome_custom_logic(records)
    records = sort_records(records)     if datatable.orderable?
    records = paginate_records(records) if datatable.paginate?
    records
  end

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions