I have a working solution for this.

I created a third table, which reads the rows from each cat and dog table 
and then inserts the values as new rows into the new table. That table is 
then passed into SQLFORM.grid().

It's not pretty, but it works while I continue to look for a more elegant 
solution.

On Saturday, April 22, 2017 at 4:51:21 PM UTC-4, George D Elig wrote:
>
> I have the following tables defined and would like to display rows of 
> cats, followed by rows of dogs
>
> db.define_table(‘cat’,
>
> Field('name', 'string', length=45),
>
> Field(‘age’, ‘integer’),
>
> Field(‘apt_time’,’datetime’)
>
> )
>
> db.define_table(‘dog’,
>
> Field('name', 'string', length=45),
>
> Field(‘age’, ‘integer’),
>
> Field(‘apt_time’,’datetime’)
>
> )
>
>
> #Controller
>
> query = ((db.cat.age == 3) | (db.dog.age == 3))
>
> union_rows = db(query).select()
>
> print union_rows
>
>
> The returned value is a single row object, containing an entry for each 
> table.
>
> <Row {‘cat’: {'name': ‘FLUFFY’, 'age': 3L, 'apt_time': 
> datetime.datetime(2017, 4, 22, 16, 22, 10), }, ‘dog’: {'name': ‘SPOT’, 
> 'age': 3L, 'apt_time': datetime.datetime(2017, 4, 22, 16, 22, 10), }}>
>
> The output from SQLFORM.grid is below
>
> *FLUFFY     3      2017-04-22 16:22:10  SPOT         3      2017-04-22 
> 16:22:10*
>
>
>
> What I need are two row objects, displayed in the SQLFORM as two rows.
> *FLUFFY     3      2017-04-22 16:22:10*
> *SPOT         3      2017-04-22 16:22:10*
>
> I attempted to append row objects but that raises incompatible types, 
> which I believe is because of the different table names.
>
>
>    
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.

Reply via email to