system system.base system.caching system.caching.dependencies system.collections system.console system.db system.db.ar system.db.schema system.db.schema.mssql system.db.schema.mysql system.db.schema.oci system.db.schema.pgsql system.db.schema.sqlite system.i18n system.i18n.gettext system.logging system.utils system.validators system.web system.web.actions system.web.auth system.web.filters system.web.helpers system.web.renderers system.web.services system.web.widgets system.web.widgets.captcha system.web.widgets.pagers

CTreeView

system.web.widgets
继承 class CTreeView » CWidget » CBaseController » CComponent
可用自 1.0
版本 $Id$
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 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 url to be the URL that can serve the tree view data upon request.

公共属性

隐藏继承的属性

属性类型描述被定义在
actionPrefix string the prefix to the IDs of the actions. CWidget
animated string|integer animation speed. CTreeView
collapsed boolean whether the tree should start with all branches collapsed. CTreeView
control string container for a tree-control, allowing the user to expand, collapse and toggle all branches with one click. CTreeView
controller CController the controller that this widget belongs to. CWidget
cookieId string The cookie name to use when persisting via persist:"cookie". CTreeView
cssFile mixed the CSS file used for the widget. CTreeView
data array the data that can be used to generate the tree view content. CTreeView
htmlOptions array additional HTML attributes that will be rendered in the UL tag. CTreeView
id string id of the widget. CWidget
options array additional options that can be passed to the constructor of the treeview js object. CTreeView
owner CBaseController owner/creator of this widget. CWidget
persist string Persist the tree state in cookies or the page location. CTreeView
prerendered boolean Set to skip rendering of classes and hitarea divs, assuming that is done by the serverside. CTreeView
toggle string Callback when toggling a branch. CTreeView
unique boolean set to allow only one branch on one level to be open (closing siblings which opening). CTreeView
url string|array the URL to which the treeview can be dynamically loaded (in AJAX). CTreeView
viewPath string Returns the directory containing the view files for this widget. CWidget

受保护的属性

隐藏继承的属性

属性类型描述被定义在
clientOptions array the javascript options CTreeView

公共方法

隐藏继承的方法

方法描述被定义在
__call() Calls the named method which is not a class method. CComponent
__construct() Constructor. CWidget
__get() Returns a property value, an event handler list or a behavior based on its name. CComponent
__isset() Checks if a property value is null. CComponent
__set() Sets value of a component property. CComponent
__unset() Sets a component property to be null. CComponent
actions() Returns a list of actions that are used by this widget. CWidget
asa() Returns the named behavior object. CComponent
attachBehavior() Attaches a behavior to this component. CComponent
attachBehaviors() Attaches a list of behaviors to the component. CComponent
attachEventHandler() Attaches an event handler to an event. CComponent
beginCache() Begins fragment caching. CBaseController
beginClip() Begins recording a clip. CBaseController
beginContent() Begins the rendering of content that is to be decorated by the specified view. CBaseController
beginWidget() Creates a widget and executes it. CBaseController
canGetProperty() Determines whether a property can be read. CComponent
canSetProperty() Determines whether a property can be set. CComponent
createWidget() Creates a widget and initializes it. CBaseController
detachBehavior() Detaches a behavior from the component. CComponent
detachBehaviors() Detaches all behaviors from the component. CComponent
detachEventHandler() Detaches an existing event handler. CComponent
disableBehavior() Disables an attached behavior. CComponent
disableBehaviors() Disables all behaviors attached to this component. CComponent
enableBehavior() Enables an attached behavior. CComponent
enableBehaviors() Enables all behaviors attached to this component. CComponent
endCache() Ends fragment caching. CBaseController
endClip() Ends recording a clip. CBaseController
endContent() Ends the rendering of content. CBaseController
endWidget() Ends the execution of the named widget. CBaseController
getController() CWidget
getEventHandlers() Returns the list of attached event handlers for an event. CComponent
getId() CWidget
getOwner() CWidget
getViewFile() Looks for the view script file according to the view name. CWidget
getViewPath() Returns the directory containing the view files for this widget. CWidget
hasEvent() Determines whether an event is defined. CComponent
hasEventHandler() Checks whether the named event has attached handlers. CComponent
hasProperty() Determines whether a property is defined. CComponent
init() Initializes the widget. CTreeView
raiseEvent() Raises an event. CComponent
render() Renders a view. CWidget
renderFile() Renders a view file. CBaseController
renderInternal() Renders a view file. CBaseController
run() Ends running the widget. CTreeView
saveDataAsHtml() Generates tree view nodes in HTML from the data array. CTreeView
saveDataAsJson() Saves tree view data in JSON format. CTreeView
setId() CWidget
widget() Creates a widget and executes it. CBaseController

受保护的方法

隐藏继承的方法

方法描述被定义在
getClientOptions() CTreeView

属性详情

animated 属性
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.

clientOptions 属性 只读
protected array getClientOptions()

the javascript options

collapsed 属性
public boolean $collapsed;

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

control 属性
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.)

cookieId 属性
public string $cookieId;

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

cssFile 属性
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.

data 属性
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 in expanded.
  • id: string, optional, the ID identifying the node. This is used in dynamic loading of tree view (see url).
  • hasChildren: boolean, optional, defaults to false, whether clicking on this node should trigger dynamic loading of more tree view nodes from server. The url property must be set in order to make this effective.
  • children: array, optional, child nodes of this node.
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.

htmlOptions 属性
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

options 属性
public array $options;

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

persist 属性
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.

prerendered 属性
public boolean $prerendered;

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

toggle 属性
public string $toggle;

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

unique 属性
public boolean $unique;

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

url 属性
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 'source' whose value is 'root'. The server script should then generate the needed tree view data corresponding to the root of the tree (see 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 'source' GET parameter is the 'id' property of the node.

方法详情

getClientOptions() 方法
protected array getClientOptions()
{return} array the javascript options

init() 方法
public void init()

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

run() 方法
public void run()

Ends running the widget.

saveDataAsHtml() 方法
public static string saveDataAsHtml(array $data)
$data array the data for the tree view (see data for possible data structure).
{return} string the generated HTML for the tree view

Generates tree view nodes in HTML from the data array.

saveDataAsJson() 方法
public static string saveDataAsJson(array $data)
$data array the data for the tree view (see data for possible data structure).
{return} string the JSON representation of the 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.