Your grid should be using a query that brings in both tables, rather than 
just the Voyages table:
def Voyages():
    Voyages = SQLFORM.grid(db.EQ_Voyages.Vessel == db.EQ_Vessels.id, fields
=[db.EQ_Vessels.VesselName, db.EQ_Voyages.VesselNumber], csv=False, orderby
=[db.EQ_Vessels.VesselName, db.EQ_Voyages.VoyageNumber])
    return dict(form=Voyages)

If you're using the grid to do built in view/edit/delete, you might want to 
set field_id


On Tuesday, 5 September 2017 16:59:15 UTC+1, rafi farchi wrote:
>
> Hi
>
> I have a parent chile relationship Vessels / Voyages .
> Each vessel may have 1 or more Voyage .
>
> The Voyage Grid form attached is working fine except that i want the Order 
> to by Vessel name(from Vessels ) and then VoyageNumber (from voyages) .
> As it is written now  the order is by Vessel.id , VoyageNumber .
>
> Model
>
> ---------
>
> db.define_table('EQ_Vessels',
>
> Field('VesselCode', 'string' , length=3 , notnull = True,unique = True) ,
>
> Field('VesselName', 'string', length=50, notnull = True,unique = True) ,
>
> format='%(VesselName)s' )
>
> db.EQ_Vessels._plural='Vessels'
>
> db.define_table('EQ_Voyages',
>
> Field('Vessel','reference EQ_Vessels' ,required=True ) ,
>
> Field('VoyageNumber', 'string' , notnull = True , required=True )
>
> )
>
> db.EQ_Voyages._plural='Voyages'
>
> db.EQ_Voyages.VoyageNumber.requires=IS_NOT_IN_DB(
>
> db(db.EQ_Voyages.Vessel==request.vars.Vessel), 'EQ_Voyages.VoyageNumber')
>
> Controller
>
> -------------
>
> def Voyages():
>
> Voyages = SQLFORM.grid(db.EQ_Voyages,csv=False , 
> orderby=db.EQ_Voyages.Vessel| db.EQ_Voyages.VoyageNumber)
>
> return dict(form=Voyages)
>
>

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