...
Code Block |
---|
language | ruby |
---|
title | Compute Method |
---|
|
...
def compute
...
return self
end
... |
The compute method will fetch the calculated data you need for your report, but you still have to fill your layout objects for rendering. Each layout has a class defining its structure, and can be filled with your report data by defining a fill method ("fill_#{layout.name}") that follows the layout's cl. which adheres to that structure.
Code Block |
---|
language | ruby |
---|
title | Layout class defines structure |
---|
|
class Layouts::GroupedTable < Layouts::Base
attr_accessor :title, :headers, :groups
def initialize
self.headers = []
self.groups = []
super
end
end |
Code Block |
---|
language | ruby |
---|
title | Fill Method in Your Widget's Class |
---|
|
...
def fill_grouped_table
my_items = {
"Type1" => [ item1, item2],
"Type2" => [ item3, item4]
}
my_items.each do |header, group|
layout.headers << header
layout.groups << group
end
end |
...