I had some simiar sounding issues + some solution
https://groups.google.com/forum/?fromgroups=#!topic/web2py/fmyLPCsaoIo
but now I don't have time to examine your problem...
2013 m. balandis 14 d., sekmadienis 19:47:46 UTC+3, D. rašė:
>
> Dear Community,
>
> I just started with web2py and ran into some difficulties:
>
> I would like to display a custom table with my data. For the value of a
> specific field in each row I need the corresponding information from
> another table.
>
> This is what I have so far:
>
> def get_extended_info_for_case(case_id):
> # DB-Query here to get the fields&values I need
> return extended_info
>
> def manage():
> ext_info = lambda row: get_extended_info_for_case(row.cases.id)
> db.cases.extended_info = Field.Virtual(ext_info)
> rows = db(db.cases).select()
> headers = ["ID", "A", "B", "C", "Extended Info"]
> fields = ["id", "a", "b", "c", "extended_info"]
> table = TABLE(THEAD(TR(*[B(header) for header in headers])),
> TBODY(*[TR(*[TD(row[field]) for field in fields])
> for row in rows]))
>
> This works when the helper-function get_extended_info returns just a plain
> string. However, if I have it return a list of tuples that I can then use
> to dynamically create links within the virtualfield - one for each tuple -
> I'm lost.
>
> For example:
> extended_info = [(1,"A1"), (223,"whatever")]
>
> resulting entry in the corresponding virtualfield should be a
> concatenation of several links:
> A(A1, _href=URL("edit", args=1)), A(whatever, _href=URL("edit", args=223))
>
> How can I accomplish this? Can I integrate the query to the second
> databasetable into the first one? Or do I need nested lambdas? I have to
> admit that I don't fully understand the way lambdas and the nested
> table-construction work. Is there a way to display this in a more
> human-readable form? Or am I better of contructing my table in the view
> instead?
>
> Thanks a lot.
>
> Best regards,
> Dan
>
--
---
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.