IMPORTANT: This version of Sitefinity CMS is out of support and the respective product documentation is no longer maintained and can be outdated. Use the version selector to view a supported product version.
Feather's sfTree directive enables you to display items hierarchically and provides you with the functionality to retrieve the selected item. You can use the directive to display hierarchical tree in the frontend, as well as in the backend. For example, on a page, as well as in a widget designer. For more information, see Feather: Use content selectors outside of widget designer views.
sfTree
The sfTree is a directive with an isolated scope that is defined in a module with the same name: sfTree. For more information, see Isolating the Scope of a Directive.
The sfTree directive exposes the following attributes:
sf-request-children
sf-model
null
sf-identifier
sf-expand-on-select
sf-deselectable
sf-template-url
sf-template-assembly
sf-item-template-url
sf-item-template-assembly
sf-has-children-field
The following example demonstrates how to add a generic tree directive in a widget designer's view.
To enable AngularJs to link the sfTree directive in your custom designer view, you must load the script of the directive and add a dependency to the module. Perform the following:
DesignerView.YourView.json
JSON
designerview-yourview.js
The code above is invoked during the initial load of the sfTree directive and two root elements are added to the tree. If you select an item which is a parent, the tree expands and invokes the function. As a result, two more elements are added under the currently selected node. If the sf-has-children-field attribute is present, its scope variable is evaluated. If the attribute is not present, all elements of the tree visually appear as if they have children. If you try to expand such an element, the response is an empty array and the item no longer appears as a parent.
DesignerView.YourView.cshtml
To provide notification when an item is selected the sfTree directive emits a custom selection event. To subscribe to the selection event, use the code in Step 2 of the above procedure.
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important