def initialize_grid(klass, opts = {})
      wg = WiceGrid.new(klass, self, opts)
      self.wice_grid_instances = [] if self.wice_grid_instances.nil?
      self.wice_grid_instances << wg
      wg
    end
def initialize_grid(klass, opts = {})
      wg = WiceGrid.new(klass, self, opts)
      self.wice_grid_instances = [] if self.wice_grid_instances.nil?
      self.wice_grid_instances << wg
      wg
    end
:nodoc:
 Creates a grid object to be used in the view. This is the <i>main</i> model, and the underlying table is the default table -
 if in other parameters a column name is mentioned without the name of the table, this table is implied.
 Just like in an ordinary ActiveRecord <tt>find</tt> you can use <tt>:joins</tt>, <tt>:include</tt>, and <tt>:conditions</tt>.

 The first parameter is an ActiveRecord class name or an  ActiveRecord::Relation instance. The generated ActiveRecord call will use it as the
 receiver of the <tt>paginate</tt> method: <tt>klass.paginate(...)</tt>

 The second parameters is a hash of parameters:
 * <tt>:joins</tt> - ActiveRecord <tt>:joins</tt> option.
 * <tt>:include</tt> - ActiveRecord <tt>:include</tt> option.
   The value of `:include` can be an array of association names `include:  [:category, :users, :status]`,
   If you need to join tables to joined tables, use hashes: `include:  [:category, {users: :group}, :status]`
 * <tt>:conditions</tt> - ActiveRecord <tt>:conditions</tt> option.
 * <tt>:per_page</tt> - Number of rows per one page. The default is 10.
 * <tt>:page</tt> - The page to show when rendering the grid for the first time. The default is one, naturally.
 * <tt>:order</tt> - Name of the column to sort by. Can be of a short form (just the name of the column) if this
   is a column of the main table (the table of the main ActiveRecord model, the first parameter of <tt>initialize_grid</tt>),
   or a fully qualified name with the name of the table.
 * <tt>:order_direction</tt> - <tt>:asc</tt> for ascending or <tt>:desc</tt> for descending. The default is <tt>:asc</tt>.
 * <tt>:name</tt> - name of the grid. Only needed if there is a second grid on a page. The name serves as the base name for
   HTTP parametes, DOM IDs, etc. The shorter the name, the shorter the GET request is. The name can only contain alphanumeruc characters.
 * <tt>:enable_export_to_csv</tt> - <Enable export of the table to CSV. Read the How-To to learn what else is needed to enable CSV export.
 * <tt>:csv_file_name</tt> - Name of the exported CSV file. If the parameter is missing, the name of the grid will be used instead.
 * <tt>:csv_field_separator</tt> - field separator for CSV files. The default is defined in +CSV_FIELD_SEPARATOR+ in the config file.
 * <tt>:custom_order</tt> - used for overriding the ORDER BY clause with custom sql code (for example, including a function).
   The value of the parameter is a hash where keys are fully qualified names
   of database columns, and values the required chunks of SQL to use in the ORDER BY clause, either as strings or Proc object
   evaluating to string. See section 'Custom Ordering' in the README.
 * <tt>:saved_query</tt> - id of the saved query or the query object itself to load initially.
   Read section "Saving Queries How-To" in README for more details.
 * <tt>:after</tt> - 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.
 * <tt>:select</tt> - ActiveRecord <tt>:select</tt> option. Please do not forget that <tt>:select</tt> is ignored
   when <tt>:include</tt> is present. It is unlikely you would need <tt>:select</tt> with WiceGrid, but if you do,
   use it with care :)
 * <tt>:group</tt> - ActiveRecord <tt>:group</tt> option. Use it if you are sure you know what you are doing :)
 * <tt>:with_paginated_resultset</tt> - a callback executed from within the plugin to process records of the current page.
   Can be a lambda object or a controller method name (symbol). The argument to the callback is the array of the records.
 * <tt>:with_resultset</tt> - a callback executed from within the plugin to process all records browsable through
   all pages with the current filters. Can be a lambda object or a controller method name (symbol). The argument to
   the callback is a lambda object which returns the list of records when called. See the README for the explanation.

 Defaults for parameters <tt>:per_page</tt>, <tt>:order_direction</tt>, and <tt>:name</tt>
 can be changed in <tt>lib/wice_grid_config.rb</tt>, this is convenient if you want to set a project wide setting
 without having to repeat it for every grid instance.