Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • ActionActiveForm
  • ActionActiveFormBase
  • CActiveForm
  • CalendarEventActiveForm
  • CallActiveForm
  • CClipWidget
  • CContentDecorator
  • CFilterWidget
  • CFlexWidget
  • CHtmlPurifier
  • CInputWidget
  • CMarkdown
  • CMaskedTextField
  • CMultiFileUpload
  • COutputCache
  • COutputProcessor
  • CStarRating
  • CTabView
  • CTextHighlighter
  • CTreeView
  • CWidget
  • EventActiveForm
  • MobileActiveForm
  • NoteActiveForm
  • TimeActiveForm
  • X2ActiveForm
  • X2StarRating
  • Overview
  • Package
  • Class
  • Tree

Class CTreeView

CTreeView displays a tree view of hierarchical data.

It encapsulates the excellent tree view plugin for jQuery (http://bassistance.de/jquery-plugins/jquery-plugin-treeview/).

To use CTreeView, simply sets CTreeView::$data to the data that you want to present and you are there.

CTreeView also supports dynamic data loading via AJAX. To do so, set CTreeView::$url to be the URL that can serve the tree view data upon request.

CComponent
Extended by CBaseController
Extended by CWidget
Extended by CTreeView
Package: system\web\widgets
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/framework/web/widgets/CTreeView.php
Methods summary
public
# init( )

Initializes the widget. This method registers all needed client scripts and renders the tree view content.

Initializes the widget. This method registers all needed client scripts and renders the tree view content.

Overrides

CWidget::init()
public
# run( )

Ends running the widget.

Ends running the widget.

Overrides

CWidget::run()
protected array
# getClientOptions( )

Returns

array
the javascript options
public static string
# saveDataAsHtml( array $data )

Generates tree view nodes in HTML from the data array.

Generates tree view nodes in HTML from the data array.

Parameters

$data
array
$data the data for the tree view (see CTreeView::$data for possible data structure).

Returns

string
the generated HTML for the tree view
public static string
# saveDataAsJson( array $data )

Saves tree view data in JSON format. This method is typically used in dynamic tree view loading when the server code needs to send to the client the dynamic tree view data.

Saves tree view data in JSON format. This method is typically used in dynamic tree view loading when the server code needs to send to the client the dynamic tree view data.

Parameters

$data
array
$data the data for the tree view (see CTreeView::$data for possible data structure).

Returns

string
the JSON representation of the data
Methods inherited from CWidget
__construct(), actions(), getController(), getId(), getOwner(), getViewFile(), getViewPath(), render(), setId()
Methods inherited from CBaseController
beginCache(), beginClip(), beginContent(), beginWidget(), createWidget(), endCache(), endClip(), endContent(), endWidget(), renderFile(), renderInternal(), widget()
Methods inherited from CComponent
__call(), __get(), __isset(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Properties summary
public array $data
#
the data that can be used to generate the tree view content. Each array element corresponds to a tree view node with the following structure:
  • text: string, required, the HTML text associated with this node.
  • expanded: boolean, optional, whether the tree view node is expanded.
  • id: string, optional, the ID identifying the node. This is used in dynamic loading of tree view (see CTreeView::$url).
  • hasChildren: boolean, optional, defaults to false, whether clicking on this node should trigger dynamic loading of more tree view nodes from server. The CTreeView::$url property must be set in order to make this effective.
  • children: array, optional, child nodes of this node.
  • htmlOptions: array, additional HTML attributes (see CHtml::tag()). This option has been available since version 1.1.7.
Note, anything enclosed between the beginWidget and endWidget calls will also be treated as tree view content, which appends to the content generated from this data.
the data that can be used to generate the tree view content. Each array element corresponds to a tree view node with the following structure:
  • text: string, required, the HTML text associated with this node.
  • expanded: boolean, optional, whether the tree view node is expanded.
  • id: string, optional, the ID identifying the node. This is used in dynamic loading of tree view (see CTreeView::$url).
  • hasChildren: boolean, optional, defaults to false, whether clicking on this node should trigger dynamic loading of more tree view nodes from server. The CTreeView::$url property must be set in order to make this effective.
  • children: array, optional, child nodes of this node.
  • htmlOptions: array, additional HTML attributes (see CHtml::tag()). This option has been available since version 1.1.7.
Note, anything enclosed between the beginWidget and endWidget calls will also be treated as tree view content, which appends to the content generated from this data.
public mixed $cssFile
#

the CSS file used for the widget. Defaults to null, meaning using the default CSS file included together with the widget. If false, no CSS file will be used. Otherwise, the specified CSS file will be included when using this widget.

the CSS file used for the widget. Defaults to null, meaning using the default CSS file included together with the widget. If false, no CSS file will be used. Otherwise, the specified CSS file will be included when using this widget.

public string|array $url
#

the URL to which the treeview can be dynamically loaded (in AJAX). See CHtml::normalizeUrl() for possible URL formats. Setting this property will enable the dynamic treeview loading. When the page is displayed, the browser will request this URL with a GET parameter named 'root' whose value is 'source'. The server script should then generate the needed tree view data corresponding to the root of the tree (see CTreeView::saveDataAsJson().) When a node has a CSS class 'hasChildren', then expanding this node will also cause a dynamic loading of its child nodes. In this case, the value of the 'root' GET parameter is the 'id' property of the node.

the URL to which the treeview can be dynamically loaded (in AJAX). See CHtml::normalizeUrl() for possible URL formats. Setting this property will enable the dynamic treeview loading. When the page is displayed, the browser will request this URL with a GET parameter named 'root' whose value is 'source'. The server script should then generate the needed tree view data corresponding to the root of the tree (see CTreeView::saveDataAsJson().) When a node has a CSS class 'hasChildren', then expanding this node will also cause a dynamic loading of its child nodes. In this case, the value of the 'root' GET parameter is the 'id' property of the node.

public string|integer $animated
#

animation speed. This can be one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000). If not set, no animation is used.

animation speed. This can be one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000). If not set, no animation is used.

public boolean $collapsed
#

whether the tree should start with all branches collapsed. Defaults to false.

whether the tree should start with all branches collapsed. Defaults to false.

public string $control
#

container for a tree-control, allowing the user to expand, collapse and toggle all branches with one click. In the container, clicking on the first hyperlink will collapse the tree; the second hyperlink will expand the tree; while the third hyperlink will toggle the tree. The property should be a valid jQuery selector (e.g. '#treecontrol' where 'treecontrol' is the ID of the 'div' element containing the hyperlinks.)

container for a tree-control, allowing the user to expand, collapse and toggle all branches with one click. In the container, clicking on the first hyperlink will collapse the tree; the second hyperlink will expand the tree; while the third hyperlink will toggle the tree. The property should be a valid jQuery selector (e.g. '#treecontrol' where 'treecontrol' is the ID of the 'div' element containing the hyperlinks.)

public boolean $unique
#

set to allow only one branch on one level to be open (closing siblings which opening). Defaults to false.

set to allow only one branch on one level to be open (closing siblings which opening). Defaults to false.

public string $toggle
#

Callback when toggling a branch. Arguments: "this" refers to the UL that was shown or hidden

Callback when toggling a branch. Arguments: "this" refers to the UL that was shown or hidden

public string $persist
#

Persist the tree state in cookies or the page location. If set to "location", looks for the anchor that matches location.href and activates that part of the treeview it. Great for href-based state-saving. If set to "cookie", saves the state of the tree on each click to a cookie and restores that state on page load.

Persist the tree state in cookies or the page location. If set to "location", looks for the anchor that matches location.href and activates that part of the treeview it. Great for href-based state-saving. If set to "cookie", saves the state of the tree on each click to a cookie and restores that state on page load.

public string $cookieId
#

The cookie name to use when persisting via persist:"cookie". Defaults to 'treeview'.

The cookie name to use when persisting via persist:"cookie". Defaults to 'treeview'.

public boolean $prerendered
#

Set to skip rendering of classes and hitarea divs, assuming that is done by the serverside. Defaults to false.

Set to skip rendering of classes and hitarea divs, assuming that is done by the serverside. Defaults to false.

public array $options array()
#

additional options that can be passed to the constructor of the treeview js object.

additional options that can be passed to the constructor of the treeview js object.

public array $htmlOptions
#
additional HTML attributes that will be rendered in the UL tag. The default tree view CSS has defined the following CSS classes which can be enabled by specifying the 'class' option here:
  • treeview-black
  • treeview-gray
  • treeview-red
  • treeview-famfamfam
  • filetree
additional HTML attributes that will be rendered in the UL tag. The default tree view CSS has defined the following CSS classes which can be enabled by specifying the 'class' option here:
  • treeview-black
  • treeview-gray
  • treeview-red
  • treeview-famfamfam
  • filetree
Properties inherited from CWidget
$actionPrefix, $skin
Magic properties inherited from CWidget
$controller, $id, $owner, $viewPath
API documentation generated by ApiGen 2.8.0