Let me assume there is only one level and this cannot be arbitrarily
nested. Also I assume the initial model of this thread:
db.define_table('store_catalog',
Field('maincategory', 'string'),
Field('subcategory', 'string'),
Field('description', 'text'))
t = store_catalog
rows = db(t).select()
from collections import defaultdict
d=defaultdict(list)
for row in rows: d[row.maincategory].append(row.subcategory)
response.menu = [
[T(key), False, None, [[T(sub), False, 'link'] for sub in
sorted(d[key])]] for key in sorted(d)
]
On Saturday, 29 July 2017 08:00:40 UTC-5, Вячеслав Анатольевич wrote:
>
> Hi!
>
> Paraphrase the question, can anyone explain how to create
> a drop-down menu from a database table or show a working example?
>
>
--
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.