Module RGhost::Grid::CallbackFacade
In: grid/callback_facade.rb

The callbacks for the grid are defined here. Let‘s see them in action.

Grid::CallbackFacade examples

 grid=Grid::Matrix.new :column_padding => 1
 grid.column :title => "Id", :width => 1
 grid.column :title => "Name", :width => 3, :align => :center
 grid.column :title => "Date", :width => 3, :align => :right, :title_align => :center,  :format => lambda{|v| v.strftime("%d/%m/%Y")}
 values=('A'..'E').to_a.map{|v|  [v,"Name #{v}", Time.now]}

even_row:

 grid.even_row do
  background_row(:size => grid.width)
 end

Now before_row to create a top and bottom line:

 grid.before_row do
  horizontal_line(:top,    :size => grid.width )
  horizontal_line(:bottom, :size => grid.width)
 end

before_column:

 grid.before_column do
  vertical_line_row
 end

after_column:

 grid.after_column {  vertical_line_row  }

Moving to the header

 grid.header.before_create do
  horizontal_line(:top, :size => grid.width)
 end

Finishing the grid lines:

 grid.header.before_column do
   vertical_line_row
 end

 grid.header.after_column do
  vertical_line_row
 end

Now a adding a bold font to the header

 grid.header.before_create do
   horizontal_line(:top, :size => grid.width)
   use_tag :bold
  end

Oops. Not quite what we expected, since the entire grid used a bold font. We can use the header callback after_create to reset the font.

 grid.header.after_create do
    use_tag :normal
  end

Don‘t forget

 doc=Document.new
 doc.set grid

Methods

Public Instance methods

Executes after column create. Respond to :only and :except options

Executes before column create. Respond to :only and :except options

Executes before row. Respond to :only and :except options

Executes on even columns create. Respond to :only and :except options

Executes on even rows create. Respond to :only and :except options

Executes on odd columns create. Respond to :only and :except options

Executes on odd rows create. Respond to :only and :except options

[Validate]