Module: Fancygrid::View::Helper
- Defined in:
- lib/fancygrid/view/helper.rb
Instance Method Summary collapse
-
#fancygrid(name, options = {}, &block) ⇒ Object
Renders an existing fancygrid for the given name.
-
#format_fancygrid_value(record, column, value = nil, &format_block) ⇒ Object
Renders the given
record
,column
andvalue
with the formatter block. -
#render_fancygrid_cell(record, column, &format_block) ⇒ Object
Fetches a value from given record and applies a formatter on it.
Instance Method Details
#fancygrid(name, options = {}, &block) ⇒ Object
Renders an existing fancygrid for the given name. A rendering block may be passed to format column values.
7 8 9 10 11 |
# File 'lib/fancygrid/view/helper.rb', line 7 def fancygrid(name, ={}, &block)#:yields: column, record, value instance = @fancygrid_collection && @fancygrid_collection[name] raise "Unknown fancygrid name: '#{name}'" if instance.nil? render :template => instance.[:base_template], :locals => { :fancygrid => instance, :format_block => block } end |
#format_fancygrid_value(record, column, value = nil, &format_block) ⇒ Object
Renders the given record
, column
and value
with the formatter block.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/fancygrid/view/helper.rb', line 23 def format_fancygrid_value(record, column, value=nil, &format_block) if block_given? if defined?(Haml::Helpers) && is_haml? capture_haml(column, record, value, &format_block) else capture(column, record, value, &format_block) end #elsif !column.root.cell_template.nil? # render( :template => column.root.cell_template, :inline => true, :locals => { # :grid => column.root, # :record => record, # :column => column, # :value => value # }) else value end end |
#render_fancygrid_cell(record, column, &format_block) ⇒ Object
Fetches a value from given record and applies a formatter on it.
15 16 17 18 |
# File 'lib/fancygrid/view/helper.rb', line 15 def render_fancygrid_cell(record, column, &format_block) value = column.fetch_value_and_format(record) format_fancygrid_value(record, column, value, &format_block) end |