This syntax is not allowed:

 left=db.org.on(db.auth_user.org_ref==db.org.id).count()

Try this instead:

 count = db.auth_user.org_ref.count()
 # bad hack
 count._tablename = 'auth_user'
 count.readable = True
 count.represent = None
 count.formatter = lambda value:value
 # end bad hack
 results= SQLFORM.grid(db.org, 
                          fields=[db.org.name, db.org.jurisdiction, 
db.org.otype, db.org.id, count], 
                          left=db.org.on(db.auth_user.org_ref==db.org.id),
                          deletable=False, details=True, create=False, 
editable=False, 
                          orderby=db.org.name.upper(),
                          maxtextlength=50, paginate=20, csv=False, 
searchable=False)
    return dict(results=results)



On Saturday, 21 July 2012 11:41:24 UTC-5, david.waldrop wrote:
>
> I am trying to show the records in a table AND the count of referenced 
> items in a child table using SQLFORM.grid but am not able to get the left 
> join to work.
>
> Here is what I have been trying for the past 2+ hours with no success
>
>     results= SQLFORM.grid(db.org, 
>                           fields=[db.org.name, db.org.jurisdiction, 
> db.org.otype, db.org.id], 
>                           left=db.org.on(db.auth_user.org_ref==db.org.id
> ).count(),
>                           deletable=False, details=True, create=False, 
> editable=False, 
>                           orderby=db.org.name.upper(),
>                           maxtextlength=50, paginate=20, csv=False, 
> searchable=False)
>     return dict(results=results)
>
> tested independently this works great.  
>
> This seems way to hard and there are no clear examples I can find.  
>
> Does anyone see what is wrong, have a working example of SQLFORM.grid 
> working with a left join, or have a different approach I can try??
>

-- 



Reply via email to