-
Data Grid
- Overview
-
Data Binding
-
Paging and Scrolling
-
Editing
-
Grouping
-
Filtering and Sorting
- Focused Row
-
Row Drag & Drop
-
Selection
-
Columns
- State Persistence
-
Appearance
-
Templates
-
Data Summaries
-
Master-Detail
-
Export to PDF
-
Export to Excel
-
Adaptability
- Keyboard Navigation
-
Pivot Grid
- Overview
-
Data Binding
-
Field Chooser
-
Features
-
Export to Excel
-
Tree List
- Overview
-
Data Binding
- Sorting
- Paging
-
Editing
- Node Drag & Drop
- Focused Row
-
Selection
-
Filtering
-
Column Customization
- State Persistence
- Adaptability
- Keyboard Navigation
-
Scheduler
- Overview
-
Data Binding
-
Views
-
Features
- Virtual Scrolling
-
Grouping
-
Customization
- Adaptability
-
Html Editor
-
Chat
-
Diagram
- Overview
-
Data Binding
-
Featured Shapes
-
Custom Shapes
-
Document Capabilities
-
User Interaction
- UI Customization
- Adaptability
-
Charts
- Overview
-
Data Binding
-
Area Charts
-
Bar Charts
- Bullet Charts
-
Doughnut Charts
-
Financial Charts
-
Line Charts
-
Pie Charts
-
Point Charts
-
Polar and Radar Charts
-
Range Charts
-
Sparkline Charts
-
Tree Map
-
Funnel and Pyramid Charts
- Sankey Chart
-
Combinations
-
More Features
-
Export
-
Selection
-
Tooltips
-
Zooming
-
-
Gantt
- Overview
-
Data
-
UI Customization
- Strip Lines
- Export to PDF
- Sorting
-
Filtering
-
Gauges
- Overview
-
Data Binding
-
Bar Gauge
-
Circular Gauge
-
Linear Gauge
-
Navigation
- Overview
- Accordion
-
Menu
- Multi View
-
Drawer
-
Tab Panel
-
Tabs
-
Toolbar
- Pagination
-
Tree View
- Right-to-Left Support
-
Layout
-
Tile View
- Splitter
-
Gallery
- Scroll View
- Resizable
-
-
Editors
- Overview
- Autocomplete
-
Calendar
- Check Box
- Color Box
- Date Box
-
Date Range Box
-
Drop Down Box
-
Number Box
-
Select Box
- Switch
-
Tag Box
- Text Area
- Text Box
- Validation
- Custom Text Editor Buttons
- Right-to-Left Support
- Editor Appearance Variants
-
Forms and Multi-Purpose
- Overview
- Button Group
- Field Set
-
Filter Builder
-
Form
- Radio Group
-
Range Selector
- Numeric Scale (Lightweight)
- Numeric Scale
- Date-Time Scale (Lightweight)
- Date-Time Scale
- Logarithmic Scale
- Discrete scale
- Custom Formatting
- Use Range Selection for Calculation
- Use Range Selection for Filtering
- Image on Background
- Chart on Background
- Customized Chart on Background
- Chart on Background with Series Template
- Range Slider
- Slider
-
Sortable
-
File Management
-
File Manager
- Overview
-
File System Types
-
Customization
-
File Uploader
-
-
Actions and Lists
-
Maps
- Overview
-
Map
-
Vector Map
-
Dialogs and Notifications
-
Localization
Tree View - Node Selection and Customization
To select a node, users can click a checkbox next to it. Set the showCheckBoxesMode to "normal" or "selectAll" to display node checkboxes. The "selectAll" mode also enables a checkbox that selects all nodes simultaneously. If selectByClick is enabled, users can click nodes to select them.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
<div class="form">
<h4>Employees</h4>
@(Html.DevExtreme().TreeView()
.ID("treeview")
.DataSource(d => d.Mvc().LoadAction("Employees"))
.ItemsExpr("Items")
.SelectedExpr("Selected")
.ExpandedExpr("Expanded")
.Width(340)
.Height(320)
.ShowCheckBoxesMode(TreeViewCheckBoxMode.Normal)
.OnSelectionChanged("syncSelection")
.OnContentReady("syncSelection")
.ItemTemplate(@<text>
<div>
<%- FullName %>
(<%- Position %>)
</div>
</text>)
)
<div class="selected-container">
Selected employees
@(Html.DevExtreme().List()
.ID("selected-employees")
.Width(400)
.Height(200)
.ShowScrollbar(ShowScrollbarMode.Always)
.ItemTemplate(@<text>
<div>
<%- Prefix %> <%- FullName %> (<%- Position %>)
</div>
</text>)
)
</div>
</div>
<div class="options">
<div class="caption">Options</div>
<div class="options-container">
<div class="option">
<span>Show Check Boxes Mode:</span>
<div class="editor-container">
@(Html.DevExtreme().SelectBox()
.ID("showCheckBoxesMode")
.InputAttr("aria-label", "Show Checkboxes Mode")
.Items(new List<string> { "selectAll", "normal", "none" })
.Value("normal")
.OnValueChanged("showCheckBoxesModeValueChanged"))
</div>
</div>
<div class="option">
<span>Selection Mode:</span>
<div class="editor-container">
@(Html.DevExtreme().SelectBox()
.ID("selectionMode")
.InputAttr("aria-label", "Selection Mode")
.Items(new List<string> { "multiple", "single" })
.Value("multiple")
.OnValueChanged("selectionModeValueChanged"))
</div>
</div>
<div class="option">
<div class="caption-placeholder"> </div>
<div class="editor-container">
@(Html.DevExtreme().CheckBox()
.ID("selectNodesRecursive")
.Text("Select Nodes Recursive")
.Value(true)
.OnValueChanged("selectNodesRecursiveValueChanged"))
</div>
</div>
<div class="option">
<div class="caption-placeholder"> </div>
<div class="editor-container">
@(Html.DevExtreme().CheckBox()
.ID("selectByClick")
.Text("Select By Click")
.Value(false)
.OnValueChanged("selectByClickValueChanged"))
</div>
</div>
</div>
</div>
<script>
function syncSelection(treeView) {
var selectedEmployees = treeView.component.getSelectedNodes()
.map(function (node) { return node.itemData; });
getSelectedEmployeesList().option("items", selectedEmployees);
}
function showCheckBoxesModeValueChanged(e) {
getTreeView().option("showCheckBoxesMode", e.value);
if(e.value === 'selectAll') {
getSelectionsModeSelectBox().option('value', 'multiple');
getRecursiveCheckBox().option('disabled', false);
}
getSelectionsModeSelectBox().option('disabled', e.value === 'selectAll');
}
function selectionModeValueChanged(e) {
getTreeView().option("selectionMode", e.value);
if(e.value === 'single') {
getRecursiveCheckBox().option('value', false);
getTreeView().unselectAll();
}
getRecursiveCheckBox().option('disabled', e.value === 'single');
}
function selectNodesRecursiveValueChanged(e) {
getTreeView().option("selectNodesRecursive", e.value);
}
function selectByClickValueChanged(e) {
getTreeView().option("selectByClick", e.value);
}
function getTreeView() {
return $("#treeview").dxTreeView("instance");
}
function getSelectedEmployeesList() {
return $("#selected-employees").dxList("instance");
}
function getSelectionsModeSelectBox() {
return $("#selectionMode").dxSelectBox("instance");
}
function getRecursiveCheckBox() {
return $("#selectNodesRecursive").dxCheckBox("instance");
}
</script>
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
Use the following TreeView properties to adjust selection:
-
selectionMode
Specifies whether multiple node selection is allowed. -
selectNodesRecursive
Specifies whether nested nodes are selected together with their parent. -
selectedExpr
A data field that allows you to pre-select a node. In this demo, the data field is called selected, and it is set to true for the "Victor Norris" node (see the data source). -
onSelectionChanged
A function that allows you to handle selection changes. In this demo, it is used to synchronize the List with the TreeView.
The TreeView also provides the following methods to manage selection programmatically:
-
selectItem / unselectItem
Selects or unselects a single node. Accepts the node key, data object, or DOM node. -
selectAll() / unselectAll()
Selects or unselects all nodes. -
getSelectedNodes() / getSelectedNodeKeys()
Gets the selected nodes or their keys. In this demo, getSelectedNodes() is used to prepare data for the List.
This demo also shows how to specify an itemTemplate for node customization. Node data is passed to the template as an argument.