Reputation: 21597
What is the best way to make the headers for SQLFORM.grid. I've tried inserting a '\n' in the field header and passing a list, but neither worked.
Upvotes: 1
Views: 688
Reputation: 25536
You need to insert a <br />
, which you can do as follows:
Using HTML helpers:
CAT('Line 1', BR(), 'Line 2')
or wrapping raw HTML in an XML()
object (to prevent escaping when serialized in the view):
XML('Line 1<br />Line 2')
Note, instead of using the "headers" argument to SQLFORM.grid
, you can directly specify the label to be used for a given database table field:
db.define_table('mytable',
Field('myfield', label=CAT('My', BR(), 'Label')))
or after the table has already been defined:
db.mytable.myfield.label = CAT('My', BR(), 'Label')
When you define a label for the field, it will be used in all SQLFORMs, SQLTABLEs, and SQLFORM.grids, so you only have to define it once.
Upvotes: 2