[web2py] Nested References in Smart Grid

2014-01-08 Thread MVolpes
Hi 

I have been using this framework for the last few days and I am in awe a 
fantastic framework. I have come from a strong .net and php framework back 
ground and wanted to learn python this has already taught me so much!!

I have a question that hopefully can be answered easily and maybe I am 
overlooking something.

I have the smart grid working well however i want to display a reference of 
a reference eg

Vehicle > Model > Make



Please bare in mind i am using a legacy db

Model
#
db.define_table('tblmake',
Field('MakeID','id'),
Field('Make','string'),
format="%(Make)s",
migrate=False)


#
db.define_table('tblmodels',
Field('Model','string'),
Field('ModelID','id'),
Field('MakeID','reference tblmake'),
format="%(Model)s",
migrate=False)


#
db.define_table('tblvehicles',
Field('VehicleID','id'),
Field('Registration','string'),
Field('Driver','string'),
Field('Model','reference tblmodels'),
migrate=False)

Controller

vehiclefields = [db.tblvehicles.Registration, db.tblvehicles.Driver, 
db.tblvehicles.Model]

vehiclelinks = [lambda row: A('View 
Post',_href=URL("search","test",args=[row.VehicleID]))]
vehicles = SQLFORM.smartgrid(db.tblvehicles, orderby="VehicleID Desc", 
fields=vehiclefields, formname="vehiclegrid",
 details=False, editable=False, 
deletable=False,links=vehiclelinks, linked_tables=False)

I would like to display the db.tblmake.Make field 

How can I do this?
Can I do this?

I have tried adding various combinations but with no luck

Any help would be greatly appreciated

-- 
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/groups/opt_out.


[web2py] Re: Nested References in Smart Grid

2014-01-08 Thread MVolpes
Thank you that worked however as pointed out its quite slow.

I ended up creating a view joining the tblmodels and tblmake and reference that

Thank you

-- 
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/groups/opt_out.


[web2py] Set Field Type Dynamically

2014-01-08 Thread MVolpes
Hi

I am loving the smart grid but the amount of references is killing 
itvery slow.

Removing the references and using multiple lefts is a workable option 
however I do want the goodness of references when editing a particular row 
in the edit field

Can I change the type dynmaically?

eg it is a integer I would set it to reference

I have tried 

db.tablename.field.type = "reference othertable" this changes it when I view

print db.tablename.field
>>"reference othertable"

but when applied to the gridnothing happens

-- 
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/groups/opt_out.


[web2py] Re: Set Field Type Dynamically

2014-01-09 Thread MVolpes
Awesome thanks!!!

I know have a light weight but full featured grid!

-- 
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/groups/opt_out.