Is there an easy way to strip HTML markup from SQLFORM.grid's CSV/TSV
export? I realize I probably need to create a custom export function, but
curious if there is an argument or a one liner that would do the trick. Or
is there a better way to format the display?
I have the following controller function:
@auth.requires_login()
def index():
response.title = 'Computer Inventory'
db.inventory.id.readable = False
db.inventory.cpu_status.represent = lambda cpu_status, row: \
SPAN(row.cpu_status,
_style='text-transform: uppercase; font-weight: bold;
padding:5px; color: %s; background-color: %s' %
('black' if row.cpu_status == 'Staged' else 'white','red' if
row.cpu_status == 'Repair' else 'gold'
if row.cpu_status == 'Staged' else 'green' if row.cpu_status
== 'In Use' else 'black'))
grid = SQLFORM.grid(db.inventory, csv=True)
return locals()
When I export as CSV/TSV (as displayed to the user) all values for
db.inventory.cpu_status are wrapped in SPAN tags for example:
<span style='text-transform: uppercase; font-weight: bold; padding:5px;
color: white; background-color: black'>VALUE</span>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.