Fork me on GitHub

Dynatree with Static Content

Define a tree of dicts with each value a tuple:

sample_tree = {
    'animal': ('Animals', {
        'mammal': ('Mammals', {
            'elephant': ('Elephant', None),
            'ape': ('Ape', None),
            'horse': ('Horse', None),
        'bird': ('Birds', {
            'duck': ('Duck', None),
            'swan': ('Swan', None),
            'turkey': ('Turkey', None),
            'hummingbird': ('Hummingbird', None),

Then the widget can be factored so:

factory('#field:dynatree', props={
    'label': 'Select single value',
    'value': '',
    'source': sample_tree,
  • Animals
    • Mammals
      • Horse
      • Ape
      • Elephant
    • Birds
      • Turkey
      • Swan
      • Hummingbird
      • Duck

Dynatree with JSON

A JSON address needs to be provided i order to use this feature. Here it is under http://.../yafowil.widget.dynatree.json. Then the widget is defined this way:

factory('#field:dynatree', props={
    'label': 'Select multiple',
    'value': '',
    'source': 'yafowil.widget.dynatree.json',
    'selectMode': 2,