ExtJS Tree Widget Tutorial

Installation

easy_install tw.extjs

Usage

Widget definition:

from tw.extjs import TreeView
extTree = TreeView(divID='treeView1', fetch='fetchTree')

Server Side

@expose('myproject.templates.tableview')
def ext(self):
    pylons.c.tree = extTree
    return dict()

Template Code

${tmpl_context.tree()}

Fetch Code

import simplejson
def _getData(self, node):
    #return a list of dictionaries
    #dictionaries have the format:
    # {'text':visible_node_name, 'id':identifier, 'cls':'file'|'folder', 'allowChildren':False, 'leaf':True}
    #return the data for a given node
    #more here soon
    pass


@expose()
def fetchTree(self, node):
    r = [self._getData(node),]
    return simplejson.dumps(r)

Todo

Difficulty: Medium. This entire tutorial is code snippets. Add some text to explain what is going on