TreeViewBuilder
Properties
WriteAction - Func
Methods
Items(System.Action)
Defines the items in the TreeView
Parameters
addAction - System.Action<TreeViewItemFactory>
The add action.
RETURNS
Returns the current TreeViewBuilder instance.
Example
@( Html.Kendo().TreeView()
.Name("TreeView")
.Items(items =>
{
items.Add().Text("First Item");
items.Add().Text("Second Item");
})
)
HighlightPath(System.Boolean)
Select item depending on the current URL.
Parameters
value - System.Boolean
If true the item will be highlighted.
RETURNS
Returns the current TreeViewBuilder instance.
Example
@( Html.Kendo().TreeView()
.Name("TreeView")
.HighlightPath(true)
)
ExpandAll(System.Boolean)
Expand all the items.Applicable when local data binding is used.
Parameters
value - System.Boolean
If true all the items will be expanded.
RETURNS
Returns the current TreeViewBuilder instance.
Example
@( Html.Kendo().TreeView()
.Name("TreeView")
.ExpandAll(true)
)
DataSource(System.Action)
Configure the DataSource of the component
Parameters
configurator - System.Action<HierarchicalDataSourceBuilder>
The action that configures the DataSource of the component.
RETURNS
Returns the current TreeViewBuilder instance.
Example
@( Html.Kendo().TreeView()
.Name("TreeView")
.DataSource(dataSource => dataSource
.Read(read => read
.Action("Employees", "TreeView")
)
)
)
DataSource(System.String)
Set ID of the DataSource that to be used for data binding
Parameters
dataSourceId - System.String
RETURNS
Returns the current TreeViewBuilder instance.
BindTo(System.Collections.Generic.IEnumerable)
Binds the TreeView to a list of items. Use if a hierarchy of items is being sent from the controller; to bind the TreeView declaratively, use the Items() method.
Parameters
items - System.Collections.Generic.IEnumerable<TreeViewItemModel>
The list of items
RETURNS
Returns the current TreeViewBuilder instance.
Example
@( Html.Kendo().TreeView()
.Name("TreeView")
.BindTo(model)
)
BindTo(System.Collections.IEnumerable,System.Action)
Binds the TreeView to a list of objects. The TreeView will create a hierarchy of items using the specified mappings.
Parameters
dataSource - System.Collections.IEnumerable
The data source.
factoryAction - System.Action<NavigationBindingFactory>
The action which will configure the mappings
RETURNS
Returns the current TreeViewBuilder instance.
Example
@( Html.Kendo().TreeView()
.Name("TreeView")
.BindTo(Model, mapping => mapping
.For<Customer>(binding => binding
.Children(c => c.Orders) // The "child" items will be bound to the the "Orders" property
.ItemDataBound((item, c) => item.Text = c.ContactName) // Map "Customer" properties to TreeViewItem properties
)
.For<Order<(binding => binding
.Children(o => null) // "Orders" do not have child objects so return "null"
.ItemDataBound((item, o) => item.Text = o.OrderID.ToString()) // Map "Order" properties to TreeViewItem properties
)
)
)
BindTo(System.Collections.Generic.IEnumerable,System.Action)
Binds the TreeView to a list of objects. The TreeView will be "flat" which means a TreeView item will be created for every item in the data source.
Parameters
dataSource - System.Collections.Generic.IEnumerable<T>
The data source.
itemDataBound - System.Action<TreeViewItem,T>
The action executed for every data bound item.
RETURNS
Returns the current TreeViewBuilder instance.
Example
@( Html.Kendo().TreeView()
.Name("TreeView")
.BindTo(new []{"First", "Second"}, (item, value) =>
{
item.Text = value;
})
)
Animation(System.Boolean)
Use to enable or disable animation of the TreeView.
Parameters
enable - System.Boolean
The boolean value.
RETURNS
Returns the current TreeViewBuilder instance.
Example
@( Html.Kendo().TreeView()
.Name("TreeView")
.Animation(false) //toggle effect
)
Animation(System.Action)
Configures the animation effects of the widget.
Parameters
animationAction - System.Action<ExpandableAnimationBuilder>
The action which configures the animation effects.
RETURNS
Returns the current TreeViewBuilder instance.
Example
@( Html.Kendo().TreeView()
.Name("TreeView")
.Animation(animation =>
{
animation.Expand(open =>
{
open.SlideIn(SlideDirection.Down);
});
})
)
CheckboxTemplate(System.String)
Defines the template that renders the checkboxes in the TreeView. The available fields in the template are: - item: The data item of the given node. - treeview: The TreeView options.
Parameters
template - System.String
The value that configures the checkbox template.
RETURNS
Returns the current TreeViewBuilder instance.
Example
@(Html.Kendo().TreeView()
.Name("TreeView")
.Checkboxes(checkboxes => checkboxes
.Name("checkedFiles")
.CheckChildren(true)
)
.CheckboxTemplate("<input type='checkbox' name='checkedFiles[#= item.id #]' value='true' />")
)
CheckboxTemplateId(System.String)
Defines the template that renders the checkboxes in the TreeView. The available fields in the template are: - item: The data item of the given node. - treeview: The TreeView options.
Parameters
templateId - System.String
The "id" attribute of the external Kendo UI Template.
RETURNS
Returns the current TreeViewBuilder instance.
Example
@(Html.Kendo().TreeView()
.Name("TreeView")
.Checkboxes(checkboxes => checkboxes
.Name("checkedFiles")
.CheckChildren(true)
)
.CheckboxTemplateId("checkBoxTemplate")
)
<script id="checkBoxTemplate" type="text/x-kendo-template">
<input type='checkbox' name='checkedFiles[#= item.id #]' value='true' />
</script>
CheckboxTemplateView(Microsoft.AspNetCore.Html.IHtmlContent)
Defines the template that renders the checkboxes in the TreeView. The available fields in the template are: - item: The data item of the given node. - treeview: The TreeView options.
Parameters
templateView - Microsoft.AspNetCore.Html.IHtmlContent
The Razor View that contains the checkbox template.
RETURNS
Returns the current TreeViewBuilder instance.
Example
@(Html.Kendo().TreeView()
.Name("TreeView")
.Checkboxes(checkboxes => checkboxes
.Name("checkedFiles")
.CheckChildren(true)
)
.CheckboxTemplateView(Html.Partial("TemplateView"))
)
CheckboxTemplateHandler(System.String)
Defines the template that renders the checkboxes in the TreeView. The available fields in the template are: - item: The data item of the given node. - treeview: The TreeView options.
Parameters
templateHandler - System.String
he JavaScript function that will return the checkbox template.
RETURNS
Returns the current TreeViewBuilder instance.
Example
@(Html.Kendo().TreeView()
.Name("TreeView")
.Checkboxes(checkboxes => checkboxes
.Name("checkedFiles")
.CheckChildren(true)
)
.CheckboxTemplateHandler("getCheckBoxTemplate")
)
<script>
function getCheckBoxTemplate(data) {
return `<input type='checkbox' name='checkedFiles[${data.item.id}]' value='true' />`;
}
</script>
CheckboxTemplate(Kendo.Mvc.UI.Fluent.TemplateBuilder)
Defines the template that renders the checkboxes in the TreeView. The available fields in the template are: - item: The data item of the given node. - treeview: The TreeView options.
Parameters
template - TemplateBuilder<TModel>
A Template component that configures the checkbox template.
RETURNS
Returns the current TreeViewBuilder instance.
Example
@(Html.Kendo().TreeView()
.Name("TreeView")
.Checkboxes(checkboxes => checkboxes
.Name("checkedFiles")
.CheckChildren(true)
)
.CheckboxTemplate(Html.Kendo().Template().AddHtml("<input type='checkbox' name='checkedFiles[${data.item.id}]' value='true' />"))
)
AutoBind(System.Boolean)
If set to false the widget will not bind to the data source during initialization. In this case data binding will occur when the change event of the data source is fired. By default the widget will bind to the data source specified in the configuration.
Parameters
value - System.Boolean
The value for AutoBind
RETURNS
Returns the current TreeViewBuilder instance.
AutoScroll(System.Boolean)
If set to true the widget will auto-scroll the containing element when the mouse/finger is close to the top/bottom of it.
Parameters
value - System.Boolean
The value for AutoScroll
RETURNS
Returns the current TreeViewBuilder instance.
AutoScroll()
If set to true the widget will auto-scroll the containing element when the mouse/finger is close to the top/bottom of it.
RETURNS
Returns the current TreeViewBuilder instance.
Checkboxes(System.Action)
If true or an object, renders checkboxes beside each node.
Parameters
configurator - System.Action<TreeViewCheckboxesSettingsBuilder>
The configurator for the checkboxes setting.
RETURNS
Returns the current instance of TreeViewBuilder .
Checkboxes()
If true or an object, renders checkboxes beside each node.
RETURNS
Returns the current instance of TreeViewBuilder .
Checkboxes(System.Boolean)
If true or an object, renders checkboxes beside each node.
Parameters
enabled - System.Boolean
Enables or disables the checkboxes option.
RETURNS
Returns the current instance of TreeViewCheckboxesSettingsBuilder .
DataImageUrlField(System.String)
Sets the field of the data item that provides the image URL of the TreeView nodes.
Parameters
value - System.String
The value for DataImageUrlField
RETURNS
Returns the current TreeViewBuilder instance.
DataSpriteCssClassField(System.String)
Sets the field of the data item that provides the sprite CSS class of the nodes. If an array, each level uses the field that is at the same index in the array, or the last item in the array.
Parameters
value - System.String
The value for DataSpriteCssClassField
RETURNS
Returns the current TreeViewBuilder instance.
DataTextField(System.String[])
Sets the field of the data item that provides the text content of the nodes. If an array, each level uses the field that is at the same index in the array, or the last item in the array.
Parameters
value - System.String[]
The value for DataTextField
RETURNS
Returns the current TreeViewBuilder instance.
DataUrlField(System.String)
Sets the field of the data item that provides the link URL of the nodes.
Parameters
value - System.String
The value for DataUrlField
RETURNS
Returns the current TreeViewBuilder instance.
DragAndDrop(System.Action)
Disables (false) or enables (true) drag-and-drop of the nodes. If configured as an object allows disabling click move click interaction as an alternative of dragging.
Parameters
configurator - System.Action<TreeViewDragAndDropSettingsBuilder>
The configurator for the draganddrop setting.
RETURNS
Returns the current instance of TreeViewBuilder .
DragAndDrop()
Disables (false) or enables (true) drag-and-drop of the nodes. If configured as an object allows disabling click move click interaction as an alternative of dragging.
RETURNS
Returns the current instance of TreeViewBuilder .
DragAndDrop(System.Boolean)
Disables (false) or enables (true) drag-and-drop of the nodes. If configured as an object allows disabling click move click interaction as an alternative of dragging.
Parameters
enabled - System.Boolean
Enables or disables the draganddrop option.
RETURNS
Returns the current instance of TreeViewDragAndDropSettingsBuilder .
LoadOnDemand(System.Boolean)
Indicates whether the child DataSources should be fetched lazily when parent groups get expanded. Setting this to false causes all child DataSources to be loaded at initialization time.
Parameters
value - System.Boolean
The value for LoadOnDemand
RETURNS
Returns the current TreeViewBuilder instance.
Messages(System.Action)
The text messages displayed in the widget. Use it to customize or localize the messages.
Parameters
configurator - System.Action<TreeViewMessagesSettingsBuilder>
The configurator for the messages setting.
RETURNS
Returns the current instance of TreeViewBuilder .
Template(System.String)
Template for rendering each node.
Parameters
value - System.String
The value for Template
RETURNS
Returns the current TreeViewBuilder instance.
TemplateId(System.String)
Template for rendering each node.
Parameters
templateId - System.String
The ID of the template element for Template
RETURNS
Returns the current TreeViewBuilder instance.
TemplateView(Microsoft.AspNetCore.Html.IHtmlContent)
Template for rendering each node.
Parameters
templateView - Microsoft.AspNetCore.Html.IHtmlContent
The view that contains the template for Template
RETURNS
Returns the current TreeViewBuilder instance.
TemplateHandler(System.String)
Template for rendering each node.
Parameters
templateHandler - System.String
The handler that returs the template for Template
RETURNS
Returns the current TreeViewBuilder instance.
Template(Kendo.Mvc.UI.Fluent.TemplateBuilder)
Template for rendering each node.
Parameters
template - TemplateBuilder<TModel>
A Template component that configures the template.
RETURNS
Returns the current TreeViewBuilder instance.
Size(Kendo.Mvc.UI.ComponentSize)
Sets the size of the component.
Parameters
value - ComponentSize
The value for Size
RETURNS
Returns the current TreeViewBuilder instance.
Events(System.Action)
Configures the client-side events.
Parameters
configurator - System.Action<TreeViewEventBuilder>
The client events action.
RETURNS
Returns the current TreeViewBuilder instance.
Example
@(Html.Kendo().TreeView()
.Name("TreeView")
.Events(events => events
.Change("onChange")
)
)
ToComponent()
Returns the internal view component.
RETURNS
The instance that represents the component.
Expression(System.String)
Sets the name of the component.
Parameters
modelExpression - System.String
RETURNS
Returns the current instance.
Explorer(Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer)
Sets the name of the component.
Parameters
modelExplorer - Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer
RETURNS
Returns the current instance.
Name(System.String)
Sets the name of the component.
Parameters
componentName - System.String
The name.
RETURNS
Returns the current instance.
Deferred(System.Boolean)
Suppress initialization script rendering. Note that this options should be used in conjunction with
Parameters
deferred - System.Boolean
RETURNS
Returns a DeferredWidgetBuilder instance.
HtmlAttributes(System.Object)
Sets the HTML attributes.
Parameters
attributes - System.Object
The HTML attributes.
RETURNS
Returns the current instance.
HtmlAttributes(System.Collections.Generic.IDictionary)
Sets the HTML attributes.
Parameters
attributes - System.Collections.Generic.IDictionary<String,Object>
The HTML attributes.
RETURNS
Returns the current instance.
ScriptAttributes(System.Object,System.Boolean)
Sets the JavaScript attributes to the initialization script.
Parameters
attributes - System.Object
The JavaScript attributes.
overrideAttributes - System.Boolean
Argument which determines whether attributes should be overriden.
RETURNS
Returns the current instance.
ScriptAttributes(System.Collections.Generic.IDictionary,System.Boolean)
Sets the JavaScript attributes to the initialization script.
Parameters
attributes - System.Collections.Generic.IDictionary<String,Object>
The JavaScript attributes.
overrideAttributes - System.Boolean
Argument which determines whether attributes should be overriden.
RETURNS
Returns the current instance.
Render()
Renders the component in place.
ToHtmlString()
Returns the HTML representation of the component.
WriteTo(System.IO.TextWriter,System.Text.Encodings.Web.HtmlEncoder)
Parameters
writer - System.IO.TextWriter
encoder - System.Text.Encodings.Web.HtmlEncoder
ToClientTemplate()
Returns the client template for the component.
AsModule(System.Boolean)
Specifies whether the initialization script of the component will be rendered as a JavaScript module.
Parameters
value - System.Boolean
RETURNS
Returns the current instance.