This will return all the data that DataTables expects including all the relevant rows from the database.
# File app/datatables/subtrades_datatable.rb, line 6 def as_json(options = {}) conditions = if params[:sSearch].present? ["LOWER(name) LIKE :q", q: "%#{params[:sSearch].downcase}%"] else {} end as_datatable(@options[:trade].subtrades, conditions) end
This fetches the correct page of data in the correct order.
# File app/datatables/subtrades_datatable.rb, line 16 def data_hash(subtrade) { id: subtrade.id, name: subtrade.name, description: subtrade.description, action: admin_action_link(subtrade) } end
Provide the sequence in which columns to be sorted.
# File app/datatables/subtrades_datatable.rb, line 26 def sort_columns ['name', 'description'] end