ok! 2012/9/2 Massimo Di Pierro <massimo.dipie...@gmail.com>
> Can you send me a patch and open a ticket about ignored fields? Thanks. > > > On Sunday, 2 September 2012 02:25:56 UTC-5, mweissen wrote: >> >> I want to use the export-feature of SQLFORM.grid. There are some >> proposals and questions: >> >> ------------------------------**------------------------------** >> ------------------------------**--------- >> >> (1) Using the parameter *csv=False* or *csv=True* I can only choose no >> exports or all export formats. But there is a new parameter * >> exportclasses*. It seems to be intended for new forms of lists. With the >> following changes the parameter *exportclasses *could be used to switch >> off some lists e.g. "*csv_with_hidden-cols*" >> >> Change gluon/sqlhtml.py, 1839f from >> >> if export_type in exportManager: >> value = exportManager[export_type] >> clazz = value[0] if hasattr(value, '__getitem__') else >> value >> oExp = clazz(rows) >> filename = '.'.join(('rows', oExp.file_ext)) >> response.headers['Content-**Type'] = oExp.content_type >> response.headers['Content-**Disposition'] = \ >> 'attachment;filename='+**filename+';' >> raise HTTP(200, oExp.export(),**response.**headers) >> >> to >> >> if export_type in exportManager: >> value = exportManager[export_type] >> *if value:* >> clazz = value[0] if hasattr(value, '__getitem__') >> else value >> oExp = clazz(rows) >> filename = '.'.join(('rows', oExp.file_ext)) >> response.headers['Content-**Type'] = >> oExp.content_type >> response.headers['Content-**Disposition'] = \ >> 'attachment;filename='+**filename+';' >> raise HTTP(200, oExp.export(),**response.**headers) >> >> and lines 2081f from >> >> if csv and nrows: >> export_links =[] >> for k,v in sorted(exportManager.items()): >> label = v[1] if hasattr(v, "__getitem__") else k >> link = url2(vars=dict( >> order=request.vars.order or '', >> _export_type=k, >> keywords=request.vars.keywords or '')) >> export_links.append(A(T(label)**,_href=link)) >> export_menu = \ >> DIV(T('Export:'),_class="w2p_** >> export_menu",*export_links) >> >> to: >> >> if csv and nrows: >> export_links =[] >> for k,v in sorted(exportManager.items()): >> *if v:* >> label = v[1] if hasattr(v, "__getitem__") else k >> link = url2(vars=dict( >> order=request.vars.order or '', >> _export_type=k, >> keywords=request.vars.keywords or '')) >> export_links.append(A(T(label)**,_href=link)) >> export_menu = \ >> DIV(T('Export:'),_class="w2p_**export_menu" >> ,*export_links) >> >> >> Now something like >> >> exportclasses={'csv_with_**hidden_cols':*None*}, >> >> would switch off csv_with_hidden_cols >> >> ------------------------------**------------------------------** >> ------------------------------**--------- >> . >> (2) There is a css-class w2p_export_menu in the menu, but I could not >> find a class definition in web2py.css. I think something like >> >> .w2p_export_menu a { >> margin-left: 0.5em; >> border-left: 1px solid #000; >> padding-left: 0.5em; >> } >> >> .w2p_export_menu a:first-child { >> margin-left: 0; border-left: none; >> } >> >> is missing in web2py.css >> >> ------------------------------**------------------------------** >> ------------------------------**--------- >> >> (3) I think only the columns listed in >> >> SQLFORM.grid(...fields=[..]...**) >> >> should be exported, but I always get all columns. Who has an idea? >> >> ------------------------------**------------------------------** >> ------------------------------**--------- >> >> (4) tsv-export: >> If there is a field like >> >> Field('persons','list:**reference auth_user') >> >> the tsv-export puts every part of this list in its own column, but all >> persons should be in one column. >> In other words: if there is one row with 2 persons and another row with 3 >> persons the excel-table is scattered. >> >> The csv-file shows the list of persons separated with "|"s >> >> ------------------------------**------------------------------** >> ------------------------------**--------- >> >> Regards, Martin >> >> -- > > --