Add table to a list of items
Closed this issue · 1 comments
Frank004 commented
I want to have a list with a table inside. I got the list going and another sub list inside it, I want the sub list to be a table with a similar code like this table code
I got this code in my pdf.rb
List and Sub list code
def list_content
move_down 15
@inspection.inspection_sections.each do |sections|
stroke_rectangle [0,cursor], 770, 30
bounding_box([10,cursor],:width => 600) do
pad(10) {
text "#{sections.section.name}"
}
end
move_down 30
sections.inspection_components.map do |component|
[component.score,component.name]
text "Componente: #{component.name} Puntuación - #{component.score}"
end
move_down 30
end
end
Table code
def table_content
move_down 30
table inspections_rows,:position => :center do
row(0).font_style = :bold
self.header = true
self.row_colors = ['DDDDDD', 'FFFFFF']
cells.padding = 8
end
end
def inspections_rows
[['Porciento','Puntuación']] +
sections.inspecton_components.map do |component|
[component.name,component.score]
end
end
Frank004 commented
Im so sorry just figure it out after hours of trying.
Code
def list_content
move_down 15
@inspection.inspection_sections.each do |sections|
stroke_rectangle [0,cursor], 770, 30
bounding_box([10,cursor],:width => 600) do
pad(10) {
text "#{sections.section.name}"
}
end
move_down 30
data = [['Porciento','Puntuación']] +
sections.inspection_components.map do |component|
[component.name,component.score]
end
table data,:position => :center do
row(0).font_style = :bold
self.header = true
self.row_colors = ['DDDDDD', 'FFFFFF']
cells.padding = 8
end
move_down 30
end
end