On 23 January 2013 20:27, Jason Martens <m...@jasonmartens.com> wrote:

> Hello All,
>    I have a SQLFORM.grid with multiple joins that looks something like
> this:
>
> query = (db.locations.id == 10) & (db.rooms.id == db.locations.room_id) &
> (db.other.id == db.rooms.other_id)
> SQLFORM.grid(query)
>
> The problem is the edit button defaults to the other table, and I want it
> to go to the rooms table to edit the room details.  How can I fix this?
>
>
> Create your own edit-button using links = ...   which refers the correct
data to an edit function you have created.

When data from more than one table is displayed by a grid, you have to
specify which field you are using.  Here is an example:

    links = [lambda row:  A(B(T('Remove')),
                            _href = URL(r = request, c = 'authors',
                                        f = 'list_chosen_authors',
                                        vars = dict(aksie= 'remove',auid=
str(row[db.akb_articles.id]))),
                                        cid = request.cid),
             lambda row:  A(B(T('Add similar')),
                            _href = URL(r = request, c = 'authors',
                                        f = 'list_chosen_authors',
                                        vars = dict(aksie =
'add_similar',auid= str(row[db.akb_articles.id]))),
                                        cid = request.cid),
             lambda row: (A(B(T('Edit')), _target = "_blank",
                            _href = URL(r = request,
                                        c = 'authors',
                                        f = 'edit_author',
                                        vars = dict(auid = str(row[
db.akb_authors.id])))))]

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 



Reply via email to