Use as_trees 

orgchart = db(db.your_table_which_records_have_parents).select().as_trees()

See as_trees documentation



     def as_trees(self, parent_name='parent_id', children_name='children',
                 render=False):
        """
        returns the data as list of trees.
        :param parent_name: the name of the field holding the reference to 
the
                            parent (default parent_id).
        :param children_name: the name where the children of each row will 
be
                              stored as a list (default children).
        :param render: whether we will render the fields using their 
represent
                       (default False) can be a list of fields to render or
                       True to render all.
        """

Then simply serialize the result into json

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