Alex

Use represent for this:

http://web2py.com/books/default/chapter/29/06#Record-representation

Ej:

db.Word.dictionaryTipeID.represent = lambda id,row: db.DictionaryType
(id).dictionaryName




On Thu, Feb 21, 2013 at 10:35 PM, Alex Glaros <alexgla...@gmail.com> wrote:

> Instead of *db.Word.dictionaryTypeID* displaying (which is a foreign key
> in db.Word), I’d like a value from the foreign table to appear, i.e.,
> DictionaryType. dictionaryName.
>
>
> In the example below, when user cascades down to the Word table, it only
> shows db.Word.dictionaryTypeID but I’d like to add the corresponding
> DictionaryType. dictionaryName value to it.
>
>
> def search_lang():
>
>    grid = SQLFORM.smartgrid(db.HumanLanguage,
> linked_tables=['Word','DictionaryType'], fields = [db.HumanLanguage.id,
> db.HumanLanguage.languageName, db.Word.id, db.Word.wordName,
> db.Word.definition, db.DictionaryType.dictionaryName,
>
>        *db.Word.dictionaryTypeID*],
>
>        user_signature=False)
>
>    return dict(grid=grid)
>
>
> id<http://127.0.0.1:8000/tech_dictionary/default/search_lang/HumanLanguage/Word.languageID/1?keywords=&order=Word.id>
>   
> Wordname<http://127.0.0.1:8000/tech_dictionary/default/search_lang/HumanLanguage/Word.languageID/1?keywords=&order=Word.wordName>
>   
> Definition<http://127.0.0.1:8000/tech_dictionary/default/search_lang/HumanLanguage/Word.languageID/1?keywords=&order=Word.definition>
>   
> Dictionarytypeid<http://127.0.0.1:8000/tech_dictionary/default/search_lang/HumanLanguage/Word.languageID/1?keywords=&order=Word.dictionaryTypeID>
> 1 beaker    glass jar     1
>
>
> Want to replace the "1" under Dictionarytypeid with value from foreign
> table.
>
> Thanks,
>
> Alex Glaros
>
>  --
>
> ---
> 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.
>
>
>

-- 

--- 
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