Parent

Netzke::Basepack::GridPanel

Ext.grid.EditorGridPanel-based component with the following features:

Instance configuration

The following config options are supported:

Columns

Columns are configured by passing an array to the columns option. Each element in the array is either the name of model's (virtual) attribute (in which case the configuration will be fully automatic), or a hash that may contain the following configuration options as keys:

Besides these options, a column can receive any meaningful config option understood by Ext.grid.column.Column.

One-to-many association support

If the model bound to a grid belongs_to another model, GridPanel can display an “assocition column” - where the user can select the associated record from a drop-down box. You can specify which method of the association should be used as the display value for the drop-down box options by using the double-underscore notation on the column name, where the association name is separated from the association method by “__” (double underscore). For example, let’s say we have a Book that belongs_to model Author, and Author responds to first_name. This way, the book grid can have a column defined as follows:

{:name => "author__first_name"}

GridPanel will detect it to be an association column, and will use the drop-down box for selecting an author, where the list of authors will be represented by the author's first name.

In order to scope out the records displayed in the drop-down box, the scope column option can be used, e.g.:

{:name => "author__first_name", :scope => lambda{|relation| relation.where(:popular => true)}}

Add/edit/search forms

The forms will by default display the fields that correspond to the configured columns, taking over meaningful configuration options (e.g. text will be converted into fieldLabel). You may override the default fields displayed in the forms by overriding the default_fields_for_forms method, which should return an array understood by the items config property of the FormPanel. If you need to use a custom class instead of FormPanel, you may need to go an extra mile overriding the corresponding GridPanel’s child component (e.g. “add_form” or “edit_form”).

Actions

You can override GridPanel’s actions to change their text, icons, and tooltips (see api.netzke.org/core/Netzke/Actions.html).

GridPanel implements the following actions:

Class configuration

Configuration on this level is effective during the life-time of the application. One place for setting these options are in application.rb, e.g.:

config.netzke.basepack.grid_panel.column_filters_available = false

These can also be eventually set directly on the component’s class:

Netzke::Basepack::GridPanel.column_filters_available = false

Most of these options influence the amount of JavaScript code that is generated for this component’s class, in the way that the less functionality is enabled, the less code is generated.

The following class configuration options are available:

Public Instance Methods

default_bbar() click to toggle source

Override to change the default bottom toolbar

# File lib/netzke/basepack/grid_panel.rb, line 214
def default_bbar
  res = %{ add edit apply del }.map(&:to_sym).map(&:action)
  res << "-" << :add_in_form.action << :edit_in_form.action if config[:enable_edit_in_form]
  res << "-" << :search.action if config[:enable_extended_search]
  res
end
default_context_menu() click to toggle source

Override to change the default context menu

# File lib/netzke/basepack/grid_panel.rb, line 222
def default_context_menu
  res = %{ edit del }.map(&:to_sym).map(&:action)
  res << "-" << :edit_in_form.action if config[:enable_edit_in_form]
  res
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.