hi, 

i want to show parent child tree using table that have self-reference. 
actually i've tried the self-reference query, but the result is not i 
expected, is there any idea for this?

for example:
*db.py*
db.define_table('category',
    Field('category', length=10, notnull=True, unique=True),
    Field('parent', 'reference category'),
    format='%(category)s')

db.category.parent.requires=IS_EMPTY_OR(IS_IN_DB(db, 'category.category'))

db.category.bulk_insert([{'category' : 'Monitor'}, 
                         {'category' : 'Keyboard'},
                         {'category' : 'Monitor LCD', 'parent' : '1'}, 
                         {'category' : 'Monitor LED', 'parent' : '1'}, 
                         {'category' : 'Keyboard Cable', 'parent' : '2'}, 
                         {'category' : 'Keyboard Gaming', 'parent' : '2'}, 
                         {'category' : 'Keyboard Wireless', 'parent' : 
'2'}])

*output i expected *
Keyboard
- Keyboard Cable
- Keyboard Gaming
- Keyboard Wireless
Monitor
- Monitor LCD
- Monitor LED

thank you so much in advance

-- 

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


Reply via email to