10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/mongoid/data_table/base.rb', line 10
def for_data_table controller, fields, search_fields=nil, explicit_block=nil, &implicit_block
params = controller.params
search_fields ||= fields
block = (explicit_block or implicit_block)
objects = self.where(_where_conditions params[:sSearch], search_fields).
order_by(_order_by_fields params, fields).
paginate :page => _page(params),
:per_page => params[:iDisplayLength]
{:sEcho => params[:sEcho].to_i,
:iTotalRecords => self.count,
:iTotalDisplayRecords => objects.total_entries,
:aaData => _yield_and_render_array(controller, objects, block)
}.to_json.html_safe
end
|