Created
September 4, 2012 11:34
-
-
Save hidakatsuya/3620457 to your computer and use it in GitHub Desktop.
[ThinReports] 一覧表の基本
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| report = ThinReports::Report.new :layout => 'list.tlf' | |
| # 基本形 | |
| @tasks.each do |task| | |
| report.list(:list_name).add_row do |row| | |
| row.item(:name).value(task.name) | |
| end | |
| end | |
| # リストのIDが :default のときは省略できる | |
| @tasks.each do |task| | |
| report.list.add_row do |row| | |
| # 明細行の値を Hash で渡すことができる | |
| @tasks.each do |task| | |
| report.list.add_row :name => task.name | |
| # 明細行の値を Hash で渡しつつブロックで操作する | |
| @tasks.each do |task| | |
| report.list.add_row :name => task.name do |row| | |
| row.item(:name).style(:color, 'red') | |
| end | |
| # #[]メソッドを持つオブジェクトであれば #add_row へそのまま渡すことができる | |
| @tasks.each do |task| | |
| # task is instance of ActiveRecord::Base. | |
| report.list.add_row(task) | |
| end | |
| # #list メソッドはブロックを引数に取ることができる | |
| report.list do |list| | |
| @tasks.each do |task| | |
| list.add_row :name => task.name | |
| end | |
| end | |
| # #list メソッドは listオブジェクトを返す | |
| list = report.list | |
| @tasks.each do |task| | |
| list.add_row(task) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment