lib/netzke/grid/base.rb in netzke-basepack-1.0.0.1 vs lib/netzke/grid/base.rb in netzke-basepack-1.0.1.0
- old
+ new
@@ -22,39 +22,59 @@
# [model]
#
# Name of the ActiveRecord model that provides data to this Grid (e.g. "User") or the model's class (e.g. User).
# Required.
#
- # [columns]
+ # [attributes]
#
- # Explicit list of columns to be displayed in the grid; each column may be represented by a symbol (attribute name),
- # or a hash, which contains the +name+ key pointing to the attribute name and additional configuration keys (see
- # the "Configuring attributes" section below). For example:
+ # Explicit list of attributes to be displayed in the grid and its forms; each attribute may be represented by a
+ # symbol (attribute name), or a hash, which contains the +name+ key pointing to the attribute name and additional
+ # configuration keys (see the "Configuring attributes" section below). For example:
#
# class Users < Netzke::Grid::Base
# def configure(c)
# super
# c.model = User
- # c.columns = [
+ # c.attributes = [
# :first_name,
# :last_name,
- # { name: :salary, with: 50 }
+ # { name: :salary, read_only: true }
# ]
# end
# end
#
# Defaults to model attribute list.
#
+ # Note, that you can also individually override attribute configs, see +Basepack::Attributes+.
+ #
+ # [columns]
+ #
+ # Array of columns to be displayed in the grid. This overrides the +attributes+ config option. For example:
+ #
+ # class Users < Netzke::Grid::Base
+ # def configure(c)
+ # super
+ # c.model = User
+ # c.attributes = [
+ # :first_name,
+ # :last_name,
+ # { name: :salary, width: 50 }
+ # ]
+ # end
+ # end
+ #
# Note, that you can also individually override column configs (e.g. setting a column's width) by using the
- # +column+ DSL method (see +Basepack::Columns+), and override attributes (e.g. making an attribute read-only) by
- # using the +attribute+ DSL method (see +Basepack::Attributes+).
+ # +column+ DSL method (see +Basepack::Columns+).
#
+ # Defaults to attribute names listed with the +attributes+ config option.
+ #
# [form_items]
#
- # Array of form items. This may define arbitrary form layout. An item that represents a specific attribute, should
- # be specified as either a symbol (attribute name), or a hash containing the +name+ key pointing to the attribute
- # name, as well as additional configuration keys.
+ # Array of items to be displayed in the grid's forms. This overrides the +attributes+ config option and may define
+ # arbitrary form layout. An item that represents a specific attribute, should be specified as either a symbol
+ # (attribute name), or a hash containing the +name+ key pointing to the attribute name, as well as additional
+ # configuration keys.
#
# class Users < Netzke::Grid::Base
# def configure(c)
# super
# c.model = User
@@ -65,11 +85,11 @@
# { name: :salary, disabled: true }
# ]
# end
# end
#
- # Defaults to model attribute list.
+ # Defaults to attribute names listed with the +attributes+ config option.
#
# [attribute_overrides]
#
# Hash of per-attribute configurations. This allows overriding attributes configs that will be reflected by both
# corresponding grid column and form field.
@@ -102,21 +122,31 @@
#
# [strong_values]
#
# A hash of attributes to be merged atop of every created/updated record, e.g. +role_id: 1+
#
- # [edit_inline]
- # Whether record editing should happen inline (as opposed to using a form). When set to +true+, automatically sets
- # +paging+ to +true+. Defaults to +false+.
- #
# [context_menu]
#
# An array of actions (e.g. [:edit, "-", :delete] - see the Actions section) or +false+ to disable the context menu.
#
# [paging]
#
- # Set to +true+ to use pagination instead of infinite scrolling. Is automatically set to
- # +true+ if +edit_inline+ is +true+. Defaults to +false+.
+ # Type of pagination to use:
+ #
+ # * :buffered (default) - implements "infinite scrolling" with help of the Ext's buffered store
+ # * :pagination - uses the paging toolbar
+ # * :none - loads all data at once
+ #
+ # [editing]
+ #
+ # Grid editing mode:
+ #
+ # * :in_form (default) - all add/edit operations are performed via a form
+ # * :inline - all add/edit operations are performed inline, with exception of multi-line editing, which is done
+ # via a form. Note: 1) this option is not compatible with `paging` set to :buffered, 2) if no `paging` option is
+ # set, setting this option will automatically set that to :pagination.
+ # * :both - same as :inline, but there are 2 more actions added to the toolbar: "Add in form" and "Edit in form",
+ # which will use a form.
#
# [store_config]
#
# Extra configuration for the JS class's internal store (Ext.data.ProxyStore), which will override Netzke's
# defaults. For example, to modify amount of records per page (defaults to 25), do: