Ok, here's the format for my select and table creation: 

In the controller:

rows = db_mydb(db_mydb.my_table).select()
fields = db_mydb.my_table.fields
headers = [list of headers]

table = TABLE(THEAD(TR(*[B(header) for header in headers])),
                     TBODY(*[TR(*[TD(row[field]) for field in fields]) \
                                for row in rows]))
table["_class"] = "table table-striped table-bordered table-condensed"
return dict(table=table)

In the view:

<div id="table" >
{{=LOAD('default','my_table_function',ajax=True, target='table')}}
</div>



On Wednesday, July 17, 2013 11:10:35 PM UTC-4, Richard wrote:
>
> Can you show us you select and the way you make your table and view?
>
> Richard
>
>
> On Wed, Jul 17, 2013 at 11:02 PM, Woody <myl...@woodring.us 
> <javascript:>>wrote:
>
>> I don't see 'This is a test'.  The table looks exactly the same as it 
>> does without the represent statement.
>>
>> It doesn't matter what I put in the represent statement, If I have:
>>
>> db_mydb.my_table.location.**represent=lambda location,row: XML(T('This 
>> is a test'))
>>
>> 'This is a test' doesn't appear in the table.
>>
>> It also doesn't work if I put:
>>
>> db_mydb.my_table.location.**represent=lambda location,row:T('This is a 
>> test').
>>
>> No matter what I put in the represent statement, my table looks the same. 
>>  I'm obviously doing something wrong, but I can't figure out what it is.
>>
>>
>> On Wednesday, July 17, 2013 7:34:13 PM UTC-4, Richard wrote:
>>
>>> I don't understand... Do you see : This is a test ?? You don't need 
>>> XML() for use a simple T(), XML serve to escape special caracter and 
>>> accentuated one, at least that my understanding. And of course there will 
>>> be not change (all your value will be represent with : This is a test, 
>>> since you don't take care of your location in your lambda.
>>>
>>> I never try to pass html tag in a represent except a A() helper, but I 
>>> don't why it would not work.
>>>
>>> You don't really need XML in the code above (virtual field), try this :
>>>
>>> Field.Virtual('description_**for**matted', lambda row: 
>>> SPAN(row.description, _style="color:#EB0F0F;"), 
>>>
>>> or 
>>>
>>> Field.Virtual('description_**for**matted', lambda row: 
>>> TAG.span(row.description, _style="color:#EB0F0F;"),  
>>>
>>> In case there is no SPAN helper (don't remember if there is SPAN() 
>>> helper).
>>>
>>> Richard
>>>  
>>>
>>> On Wed, Jul 17, 2013 at 5:55 PM, Woody <myl...@woodring.us> wrote:
>>>
>>>> 'represent' is not working for me.  Here's my code:
>>>>
>>>> -----------------------
>>>> db_mydb.define_table('my_**table',
>>>>                 Field('ROWID', 'id'),
>>>>                 Field('location', 'string'),
>>>>                 Field('other_field', 'string'),
>>>>                 migrate=False)
>>>>
>>>> db_mydb.my_table.location.**represent=lambda location,row: XML(T('This 
>>>> is a test'))
>>>> ------------------------
>>>>
>>>> Doesn't matter what I put in the represent declaration, the data 
>>>> displayed in the table doesn't change.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Wednesday, July 17, 2013 3:34:21 PM UTC-4, Richard wrote:
>>>>
>>>>> represent!!
>>>>>
>>>>> represent=lambda value, row: XML(...) if value is not None else 
>>>>> T('N/A')
>>>>>
>>>>> Richard
>>>>>
>>>>>
>>>>>  On Wed, Jul 17, 2013 at 3:24 PM, Woody <myl...@woodring.us> wrote:
>>>>>
>>>>>> I have a table definition that uses virtual fields with XML:
>>>>>>
>>>>>> db_mydb.define_table('my_**table**',
>>>>>>                 Field('ROWID', 'id'),
>>>>>>                 Field('location', 'string'),
>>>>>>                 Field('description', 'string', required=False),
>>>>>>                 Field.Virtual('description_**for**matted', lambda 
>>>>>> row: XML('<span style="color:#EB0F0F">' + row.description + '</span>'), 
>>>>>>                 etc........
>>>>>>
>>>>>> So, using Field.Virtual, I can pass XML with HTML tags to a table. Is 
>>>>>> there a way to do this without having to create a virtual field?  In 
>>>>>> other 
>>>>>> words, I'd like to be able to add HTML formatting in a normal field 
>>>>>> definition, using XML or helper functions.
>>>>>>
>>>>>>  -- 
>>>>>>  
>>>>>> --- 
>>>>>> 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+un...@**googlegroups.com.
>>>>>>
>>>>>> For more options, visit 
>>>>>> https://groups.google.com/**grou**ps/opt_out<https://groups.google.com/groups/opt_out>
>>>>>> .
>>>>>>  
>>>>>>  
>>>>>>
>>>>>
>>>>>  -- 
>>>>  
>>>> --- 
>>>> 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+un...@**googlegroups.com.
>>>> For more options, visit 
>>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>>> .
>>>>  
>>>>  
>>>>
>>>
>>>  -- 
>>  
>> --- 
>> 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+un...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 

--- 
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/groups/opt_out.


Reply via email to