LiveTreeClient

Path: LiveTreeClient
Last Update: Mon Jan 16 14:28:27 Pacific Standard Time 2006

LiveTree Client JavaScript

This documents the LiveTree client JavaScript object. See README for general documentation about LiveTree.

Requirements

LiveTree requires Sam Stephenson’s Prototype library, available from prototype.conio.net/, and also bundled with Ruby on Rails.

Constructor

  • LiveTree(id, options)

    Create a LiveTree object.

    Arguments:

    • id - HTML element ID to give the LiveTree.
    • options - Object that may contain the following properties:
      • dataUrl - URL to read data from (required).
      • cssClass - CSS class to give the tree’s top element. Also used as prefix for class names of various sub-elements (optional).
      • cssStyle - CSS style to give the tree’s top element (optional).
      • expandRootItem - Specifies whether to expand the tree’s root item initially (default true).
      • hideRootItem - Specifies whether the root item should not be displayed (default false).
      • preloadItems - Specifies whether children of an expanded item should be pre-loaded (default +true).
      • rootItemId - Specifies the item ID of the root item to display (optional, and un-necessary if initialData is set).
      • initialData - Object that speifies data to display in the tree. If not specified, initial data will be read from server, causing a delay for the user. Of the form:
          { id: 1, name: "Root Item", children: [
                  { id: 2, name: "First child of root", children: [] },
                  { id: 3, name: "Second child of root, which has children of its own", children: [
                          { id: 4, name: "Child of second child of root", children: [] },
                  { id: 5, name: "Third child of root, which has children that will be loaded as-needed" }
          ] } ] }
        

        Note that item id 5 does not have a children property, which means the children will be loaded from the server when needed. If all the initial data has a children property, LiveTree will never request data from the server.

      • expandItemOnClick - Specifies whether to expand an item when its name is clicked (default true).
      • scroll - Specifies whether the tree will automatically scroll so that items are fully visible when expanded and in other cases (default true).
      • collapsedItemIconHtml - HTML to display the icon for collapsed items (optional).
      • expandedItemIconHtml - HTML to display the icon for expanded items (optional).
      • leafIconHtml - HTML to display the icon for leafs (optional).
      • loadingIconHtml - HTML to display the icon for loading items (optional).
      • loadingTreeHtml - HTML to display when loading initial data (optional).
      • searchingHtml - HTML to display when searching for an item (optional).
      • onClickItem - Function to call when an item is clicked (optional).
      • allowClickBranch - Specifies whether to allow clicking on branches (default true).
      • allowClickLeaf - Specifies whether to allow clicking on leaves (default true).
      • onExpandItem - Function to call when an item is expanded (optional).
      • onCollapseItem - Function to call when an item is collapsed (optional).
      • onLoadItem - Function to call when an item has finished loading (optional).

    All of the event handler functions will recieve an item parameter, which has the following properties:

    • id - Item ID.
    • name - Item’s name.
    • isLeaf - Specifies whether the item is a leaf or a branch.

Methods

  • render() - Render the LiveTree at the current position in the document and start it.
  • getHtml() - Get HTML for the tree.
  • start() - Start the tree.
  • scrollToItem(itemId) - Scroll the view to the specified item.
  • expandItem(itemId) - Expand the specified item.
  • expandParentsOfItem(itemId) - Expand the parents of the specified item.
  • activateItem(itemId) - Make the specified item the active item (highlighted).

Author and Copyright

Author:Emanuel Borsboom (www.epiphyte.ca/)
Copyright:Copyright © 2005-2006 Emanuel Borsboom
License:MIT (see LICENSE)

[Validate]