Skip to content

Record count changes #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/ajax-datatables-rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def as_json(options = {})
{
sEcho: params[:sEcho].to_i,
iTotalRecords: @model_name.count,
iTotalDisplayRecords: get_raw_records.count,
iTotalDisplayRecords: get_raw_record_count,
aaData: data
}
end
Expand All @@ -29,6 +29,10 @@ def get_raw_records
raise
end

def get_raw_record_count
raise
end

def fetch_records
search_records(sort_records(paginate_records(get_raw_records)))
end
Expand Down
4 changes: 1 addition & 3 deletions lib/generators/ajaxdatatable/USAGE
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
Description:
The cancan:ability generator creates an Ability class in the models
directory. You can move this file anywhere you want as long as it
is in the load path.
The ajaxdatatable generator creates a *_datatable model in the app/datatables directory. This class inherits from AjaxDatatablesRails
2 changes: 2 additions & 0 deletions lib/generators/filterdatatable/USAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Description:
The ajaxdatatable generator creates a *_filter_datatable model in the app/datatables directory. This class overwrites the query in it's parent class
8 changes: 8 additions & 0 deletions lib/generators/filterdatatable/filterdatatable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class FilterdatatableGenerator < Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__)
argument :model, type: :string

def generate_ajaxdatatable
template 'filter.rb', File.join('app/datatables', "#{model.tableize}_filter_datatable.rb")
end
end
8 changes: 8 additions & 0 deletions lib/generators/filterdatatable/templates/filter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class <%= model.classify.pluralize %>FilterDatatable < <%= model.classify.pluralize %>Datatable

private

def get_raw_records
# insert query here
end
end