*Solution to the error*:
*<code file=sqlhtml.py line=1253>*
elif headers=='labels':
            headers = {}
            for c in columns:
                (t,f) = c.split('.')
                try:
                    field = sqlrows.db[t][f]
                    headers[c] = field.label
                except KeyError:
                    headers[c] = ' '.join([w.capitalize() for w in
c.split('.')[-1].split('_')])
*</code>*

I am still looking for a solution to:


   1. Set labels for virtual fields (because I need to use T() in the
   virtual field label)
   2. Include the virtual fields in sqlrows.colnames automatically


2010/12/9 Ivan Matveev <[email protected]>

> > This is my working
> > code: http://snipt.net/rochacbruno/virtual-fields-in-sqltabe
> > Note the headers=None
> > So need to patch the header definition to use the virtualfieldname, or
> > better, How to define a label for a virtual field?
>
> I think you can try to add label property to your  MyVirtualFields class.
> Like:
> __init__(self):
>   self.label = "mylabel"
>
> > for work with SQLTABLE (or plugin_datatable) we need to add the colname
> for
> > every virtual field: myrows.colnames.append('task.teste')
> > How to append every virtual field to rows.colnames? I think this could be
> > done in sqlhtml.py as:
> > for field in sqlrows.virtualfields:
> > sqlrows.colnames.append('tablename.'+field)
> > Is it possible?
>
> Its late, I can be understanding you wrong.
> Why you don't want to do it by hand the way it is in your code?
>
> myrows.colnames.append('task.teste')
>



-- 

Bruno Rocha
http://about.me/rochacbruno/bio

Reply via email to