hi,
i use smartgrid with links and have a represent for that table. when the
links is clicked it returned an error, so that i must make a condition for
that.
e.g.
*models/db.py*
# on_define_shop
def on_define_shop(table):
# represent
* if 'shop' in request.function :*
table.website.represent = lambda website, field: \
A(website, _title = T("View Website"), _target = "_blank", _href = "%s" %
website) if website else ''
# create table : shop
db.define_table('shop',
Field('name'),
Field('website'),
on_define = on_define_shop,
format = '%(name)s')
# on_define_branch
def on_define_branch(table):
# represent
* if 'branch' in request.function :*
table.address.represent = lambda address, field: \
A(address, _title=T("View Maps"), _target="_blank",
_href="http://maps.google.com/maps?f=q&hl=en&geocode=&time=&date=&ttype=&q=%s,+%s,+%s"
% (field.address, field.city, field.country) ) if address else ''
table.email.represent = lambda email, field: \
XML(", ".join([A(mail, _title=T("Send to %s") % mail, _target="_blank",
_href="mailto:%s" % mail).xml() for mail in email] ) ) if email else ''
table.shop.represent = lambda shop, field: \
A(field.shop.name, _title=T("View Website"), _target="_blank", _href="%s" %
field.shop.website)
# create table : branch
db.define_table('branch',
Field('address', 'text'),
Field('city'),
Field('country'),
Field('email', 'list:string'),
Field('shop', 'reference shop'),
on_define = on_define_branch,
format = '%(address)s')
the problem is the represent is not work in the reference links (no error
occured)
e.g.
http://127.0.0.1:8000/shop/master/shop/shop/branch.shop/1
my question is from the url above how can i get the value for *branch.shop*?
already tried *if 'shop' in request.function or ** 'shop' in request.args **:
*but have the same result (represent not work, no error occured). any idea
how to fix it?
Another question is about empty data field show in grid, why some is blank
and some return None?
thanks and best regards,
stifan
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.