Perspective Tree Component - Navigation example

Here's part of one I created.

props.items
[
  {
    "label": "Home",
    "expanded": true,
    "data": {
      "url": "/"
    },
    "items": []
  },
  {
    "label": "Features",
    "expanded": true,
    "data": {
      "url": "/help"
    },
    "items": []
  },
  {
    "label": "Performance",
    "expanded": true,
    "data": {
      "url": "/myDashboard"
    },
    "items": [
      {
        "label": "MyMachines",
        "expanded": true,
        "data": {
          "url": "/areaChart/MyMachine 1P"
        },
        "items": [
          {
            "label": "Mach03",
            "expanded": true,
            "data": {
              "url": "/machine/Mach03"
            },
            "items": []
          },
          {
            "label": "Mach04",
            "expanded": true,
            "data": {
              "url": "/machine/Mach04"
            },
            "items": []
          },
          {
            "label": "Mach05",
            "expanded": true,
            "data": {
              "url": "/machine/Mach05"
            },
            "items": []
          },
          {
            "label": "Mach06",
            "expanded": true,
            "data": {
              "url": "/machine/Mach06"
            },
            "items": []
          },
          {
            "label": "Mach07",
            "expanded": true,
            "data": {
              "url": "/machine/Mach07"
            },
            "items": []
          },
          {
            "label": "Mach08",
            "expanded": true,
            "data": {
              "url": "/machine/Mach08"
            },
            "items": []
          }
        ]
      }
	]
  }
]

Tree as menu

Configure an event on the tree, set it to onItemClicked, select a script action and add the following code.

	import urllib
	pagePath = self.props.selectionData[0].value.url
	system.perspective.navigate(urllib.quote(pagePath))

You'll need to set up each URL on the Page Configuration dialog.

It works really well and makes a nice, clear, easily understood navigation system for an application or site.

4 Likes