diff --git a/CHANGELOG b/CHANGELOG index 493d2d5a..59db3258 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,6 @@ +:total_entries parameter added to initialize_grid (will_paginate) + Localization assert_keys wherever possible diff --git a/lib/wice_grid.rb b/lib/wice_grid.rb index 5c55761a..2805a9f4 100644 --- a/lib/wice_grid.rb +++ b/lib/wice_grid.rb @@ -67,7 +67,8 @@ def initialize(klass, controller, opts = {}) #:nodoc: :order_direction => Defaults::ORDER_DIRECTION, :page => 1, :per_page => Defaults::PER_PAGE, - :saved_query => nil + :saved_query => nil, + :total_entries => nil } # validate parameters @@ -104,6 +105,7 @@ def initialize(klass, controller, opts = {}) #:nodoc: @status[:order] = @options[:order] end + @status[:total_entries] = @options[:total_entries] @status[:per_page] = @options[:per_page] @status[:page] = @options[:page] @status[:conditions] = @options[:conditions] @@ -187,7 +189,6 @@ def form_ar_options(opts = {}) #:nodoc: @ar_options[:conditions] = @status[:conditions] - if @table_column_matrix.generated_conditions.size == 0 @status.delete(:f) end @@ -205,6 +206,7 @@ def form_ar_options(opts = {}) #:nodoc: if self.output_html? @ar_options[:per_page] = @status[:pp] || @status[:per_page] @ar_options[:page] = @status[:page] + @ar_options[:total_entries] = @status[:total_entries] if @status[:total_entries] end @ar_options[:joins] = @options[:joins] @@ -213,7 +215,6 @@ def form_ar_options(opts = {}) #:nodoc: def read #:nodoc: form_ar_options - # Wice.log(@ar_options.to_yaml) @resultset = self.output_csv? ? @klass.find(:all, @ar_options) : @klass.paginate(@ar_options) end diff --git a/lib/wice_grid_controller.rb b/lib/wice_grid_controller.rb index 576ebe08..1c973cfb 100644 --- a/lib/wice_grid_controller.rb +++ b/lib/wice_grid_controller.rb @@ -47,7 +47,10 @@ def save_wice_grid_queries # Read section "Saving Queries How-To" in README for more details. # * :after - defined a name of a controller method which would be called by the grid after all user input has been processed, # with a single parameter which is a Proc object. Once called, the object returns a list of all records of the current selection - # throughout all pages. See section "Integration With The Application" in the README. + # throughout all pages. See section "Integration With The Application" in the README. + # * :total_entries - If not specified, will_paginate will run a select count + # query to calculate the total number of entries. If specified, the value is passed on to :total_entries of + # will_paginate's paginate method. # # Defaults for parameters :per_page, :order_direction, :name, and :erb_mode # can be changed in lib/wice_grid_config.rb, this is convenient if you want to set a project wide setting