The problem is solved in this way:
>>> headers = {}
>>> for field in db['category'].fields:
... headers['category.'+field] =db['category'][field].label
...
>>> headers
{'category.created_on': 'Created On', 'updated_by': 'Updated By',
'category.updated_on': 'Updated On', 'category.created_by': 'Created By',
'created_by': 'Created By', 'category.name': <lazyT 'Name'>, 'created_on':
'Created On', 'category.updated_by': 'Updated By', 'category.id': 'Id',
'updated_on': 'Updated On', 'id': 'Id', 'name': <lazyT 'Nome'>}
So I think it is easy to have an headers='fieldlabel:capitalize' in the same
form we have 'fieldname:capitalize'
2010/12/6 Bruno Rocha <[email protected]>
> OK, I found that labels are in db.fieldname.label, now I just have to
> create a dict.
>
> 2010/12/6 Bruno Rocha <[email protected]>
>
> HI,
>>
>> I have a 'category' table:
>>
>> db.define_table('category',
>> Field('name',label=T('Name')),
>> signature,
>> format='%(name)s'
>> )
>>
>> which I defined a label for the field 'name'
>>
>> I need to create something like:
>>
>> list = plugin_datatable(db(db.category.id>0).select(db.category.id,
>> db.category.name),
>> _class='datatable',
>> headers = {'category.name':T('Name')},
>> )
>>
>> Is there a way to pass my previously defined labels to the SQLTABLE?
>>
>> where the 'labels' are stored? I tried db.category.labels,
>> db.category['labels'] ?
>>
>> Thanks
>>
>> --
>>
>> Bruno Rocha
>> http://about.me/rochacbruno/bio
>>
>
>
>
> --
>
> Bruno Rocha
> http://about.me/rochacbruno/bio
>
--
Bruno Rocha
http://about.me/rochacbruno/bio