This will return all the data that DataTables expects including all the relevant rows from the database.
# File app/datatables/transactions_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(User.where(id: AccountBalance.select(:user_id)), conditions) end
This fetches the correct page of data in the correct order.
# File app/datatables/transactions_datatable.rb, line 16 def data_hash(transaction) { id: transaction.id, name: transaction.name, email: transaction.email, link: view_user_transactions_link(transaction) } end
Provide the sequence in which columns to be sorted.
# File app/datatables/transactions_datatable.rb, line 26 def sort_columns ['name'] end