hi,

I have customized one of the fields of my SQLForm whereby instead of 
displaying its long content, it shows a small button that copies its 
content into the clipboard, as follows:

    db.mytable.myfield.represent = lambda value, row: TAG.button(SPAN(DIV(
row.myfield, _id="cp_"+str(row.id),_style="display:none"),_class='glyphicon 
glyphicon-copy'),_type="button",_onClick="copyToClipboard('#cp_%s'); 
$.web2py.flash('myfield copied: %s...');"% (row.id,value[:25]), _class=
"btn-primary")

( copyToClipboard() is a javascript function that pushes contents to the 
clipboard as the name suggests )

This works fine for most purposes until I try to export the table contents 
to CSV, HTML and TSV using the SQLForm.smartgrid() generated buttons with 
an error as follows:

 File ".../gluon/sqlhtml.py", line 3648, in export
    self.rows.export_to_csv_file(s, represent=True)
  File "/local/path/site-packages/pydal/objects.py", line 2603, in 
export_to_csv_file
    value = field.represent(value, record)
  File ".../controllers/analysis.py" 
<http://127.0.0.1:8000/admin/default/edit/Mordor/controllers/analysis.py>, line 
77, in <lambda>
    db.mytable.myfield.represent = lambda value, row: 
TAG.button(SPAN(DIV(row.myfield, 
_id="cp_"+str(row.id),_style="display:none"),_class='glyphicon 
glyphicon-copy'),_type="button",_onClick="copyToClipboard('#cp_%s'); 
$.web2py.flash('myfield copied: %s...');"% (row.id,value[:25]), 
_class="btn-primary")
  File "/local/path/site-packages/pydal/objects.py", line 99, in __getattr__
    raise AttributeError
AttributeError


Exporting to JSON and XML works fine though. Am I doing something wrong? Is 
there a way to have my form customization working without breaking the export 
functionality?

Thank you

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to