DxTreeView.NodeTextTemplate Property
Specifies the common template to display all nodes’ text.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v20.2.dll
NuGet Package: DevExpress.Blazor
Declaration
[Parameter]
public RenderFragment<ITreeViewNodeInfo> NodeTextTemplate { get; set; }
Property Value
Type | Description |
---|---|
RenderFragment<ITreeViewNodeInfo> | The template content. |
Remarks
The NodeTextTemplate property allows you to specify a template for the text of all TreeView nodes. Use the template’s context parameter to access a ITreeViewNodeInfo object that stores information about a node (the text, level, bound data item, etc.)
The following example demonstrates how to change the text settings for the root node and specify the multi-line text for other nodes:
<DxTreeView @ref="@treeView"
Data="@ComponentsData.ComponentSets"
ChildrenExpression="@(dataItem => ((ComponentSet)dataItem).ComponentSets)">
<NodeTextTemplate>
@{
var dataItem = (ComponentSet)context.DataItem;
}
@if (!context.IsLeaf) {
<h5 class="mt-0 d-inline-block">@dataItem.Title</h5>
}
else {
<div class="media-body">
<h5 class="mt-0">@dataItem.Title</h5>
@dataItem.Description
</div>
}
</NodeTextTemplate>
</DxTreeView>
The NodeTemplate property allows you to modify the content for all nodes.
In unbound mode, you can also use the DxTreeViewNode.TextTemplate and DxTreeViewNode.Template properties to specify templates for individual nodes.