Class: RubyMVC::Views::TableView

Inherits:
View
  • Object
show all
Defined in:
lib/ruby_mvc/views/table_view.rb

Overview

This class provides a basic TableView control based loosely on the Archistry JavaScript TreeGrid API. It requires that the data to be displayed be supplied as a TableModel instance.

Direct Known Subclasses

ActiveRecordTypeList

Instance Attribute Summary

Attributes inherited from View

#controller, #widget

Instance Method Summary collapse

Methods inherited from View

create_widget, #method_missing, #peer, widget, widget_def

Constructor Details

#initialize(model, options = {}, &block) ⇒ TableView

Returns a new instance of TableView.



35
36
37
38
# File 'lib/ruby_mvc/views/table_view.rb', line 35

def initialize(model, options = {}, &block)
  super(options, &block)
  load(model, options, &block)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RubyMVC::Views::View

Instance Method Details

#load(model, options = {}, &block) ⇒ Object

This method is used to load the view with the information in the table model.



43
44
45
46
47
48
49
50
# File 'lib/ruby_mvc/views/table_view.rb', line 43

def load(model, options = {}, &block)
  cols = columns(model, options)
  defw = "#{100 / cols.size}%"
  build_header(model, cols, defw, options)
  stack(:width => "100%") do
    model.each { |row| build_row(cols, row, defw) }
  end
end