Syncfusion ASP.NET Core TreeGrid
The TreeGrid component visualizes self-referential hierarchical data in a tabular format. It supports child/parent data binding (via childMapping or idMapping), expand/collapse of child rows, sorting, filtering, editing, paging, export, and virtualization.
⚠️ Security & Trust Boundary
- The TreeGrid skill does not perform any remote data access.
- All external API interaction is handled by a separate DataManager skill outside this skill’s trust boundary.
When to Use This Skill
- Rendering hierarchical or parent-child structured data in ASP.NET Core (e.g. project tasks, org charts, bill of materials)
- Implementing CRUD operations on tree-structured data
- Sorting, filtering, or searching across hierarchical records
- Exporting tree data to Excel or PDF
- Handling large datasets with virtual scrolling or infinite scroll
Refer to Properties & Configuration, Events & Lifecycle, and Classes & Enums Reference files for complete API lookup.
Table of Contents
Data Structure Rules
Rule 1: childMapping is MANDATORY for Hierarchical Data
Severity: 🔴 CRITICAL - Grid will not expand/collapse without this
Requirement:
CSHTML View:
<!-- ✅ REQUIRED - childMapping matches data property name exactly -->
<ejs-treegrid id="TreeGrid" dataSource="@ViewBag.data" childMapping="Children"
treeColumnIndex="1" allowPaging="true">
<e-treegrid-columns>
<e-treegrid-column field="TaskId" headerText="Task ID"
isPrimaryKey="true" textAlign="Right" width="95"></e-treegrid-column>
<e-treegrid-column field="TaskName" headerText="Task Name" width="220"></e-treegrid-column>
<e-treegrid-column field="Duration" headerText="Duration" textAlign="Right" width="100"></e-treegrid-column>
</e-treegrid-columns>
</ejs-treegrid>
<!-- ❌ WRONG - No childMapping = No expansion possible -->
<ejs-treegrid id="TreeGrid2" dataSource="@ViewBag.data">
<!-- Missing childMapping & treeColumnIndex - Won't expand! -->
</ejs-treegrid>
Data Format C# Model:
public class TreeGridItem
{
public int TaskId { get; set; }
public string TaskName { get; set; }
public int Duration { get; set; }
public List<TreeGridItem> Children { get; set; } // Must match childMapping="Children"
}
// Sample data
var data = new List<TreeGridItem>
{
new TreeGridItem
{
TaskId = 1,
TaskName = "Planning",
Duration = 5,
Children = new List<TreeGridItem> // ✅ CORRECT - nested Children property
{
new TreeGridItem { TaskId = 2, TaskName = "Identify Site", Duration = 2 },
new TreeGridItem { TaskId = 3, TaskName = "Perform Test", Duration = 3 }
}
}
};
Alternative: Flat Structure with Parent IDs:
<!-- Use idMapping + parentIdMapping instead of childMapping -->
<ejs-treegrid id="TreeGrid" dataSource="@ViewBag.flatData"
idMapping="TaskId" parentIdMapping="ParentId" treeColumnIndex="1">
...
</ejs-treegrid>
var flatData = new List<TreeGridItem>
{
new TreeGridItem { TaskId = 1, TaskName = "Planning", ParentId = null },
new TreeGridItem { TaskId = 2, TaskName = "Identify Site", ParentId = 1 },
new TreeGridItem { TaskId = 3, TaskName = "Perform Test", ParentId = 1 }
};
Rule 2: Data Type Matching is MANDATORY
Severity: 🟠 IMPORTANT - Type mismatches cause rendering/sorting issues
C# Model - Correct Types:
public class TreeGridItem
{
public int TaskId { get; set; } // ✅ int type
public string TaskName { get; set; } // ✅ string type
public DateTime StartDate { get; set; } // ✅ DateTime for date columns
public decimal Price { get; set; } // ✅ decimal for currency
}
var data = new List<TreeGridItem>
{
new TreeGridItem
{
TaskId = 1, // int, not string "1"
TaskName = "Planning",
StartDate = new DateTime(2024, 3, 15), // DateTime, not "03/15/2024"
Price = 1500.50m // decimal, not string "1500.50"
}
};
CSHTML Column Definition - Match Data Types:
<ejs-treegrid id="TreeGrid" dataSource="@ViewBag.data" childMapping="Children">
<e-treegrid-columns>
<!-- field "TaskId" is int, so type="number" -->
<e-treegrid-column field="TaskId" headerText="Task ID"
type="number" textAlign="Right" width="95"></e-treegrid-column>
<!-- field "TaskName" is string, type="string" (default) -->
<e-treegrid-column field="TaskName" headerText="Task Name" width="220"></e-treegrid-column>
<!-- field "StartDate" is DateTime, so type="date" with format -->
<e-treegrid-column field="StartDate" headerText="Start Date"
type="date" format="yMd" textAlign="Right" width="115"></e-treegrid-column>
<!-- field "Price" is decimal, type="number" with currency format -->
<e-treegrid-column field="Price" headerText="Price"
type="number" format="c2" textAlign="Right" width="100"></e-treegrid-column>
</e-treegrid-columns>
</ejs-treegrid>
❌ WRONG - Type Mismatch Issues:
// Bad model - mixing string where types should be specific
var badData = new List<TreeGridItem>
{
new TreeGridItem
{
TaskId = "1", // ❌ String instead of int
StartDate = "02/03/2024" // ❌ String instead of DateTime
}
};
// Result: Sorting fails, formatting doesn't work, expand/collapse issues
Documentation and Navigation Guide
Getting Started
📄 Read: references/getting-started.md
- NuGet installation (
Syncfusion.EJ2.AspNet.Core)
- TagHelper registration in
_ViewImports.cshtml
- CSS/script CDN setup in
_Layout.cshtml
- Basic
<ejs-treegrid> declaration
- Binding local data with
childMapping / treeColumnIndex
- Defining columns with
<e-treegrid-columns>
- Enabling paging, sorting, and filtering at startup
- Error handling with
actionFailure
Data Binding
📄 Read: references/data-binding.md
- Local data with
childMapping (nested list) and idMapping/parentIdMapping (flat list)
- Remote data via
DataManager with OData/WebAPI adaptor
- Ajax/Fetch-based binding
expandStateMapping — control initial expand/collapse state per row
- Handling null or missing parent references
Columns
📄 Read: references/columns.md
- Column
field, headerText, textAlign, width, type, format
treeColumnIndex — which column shows expand/collapse arrows
- Number/date formatting (N2, C2, yMd, custom)
- Lock columns, show/hide columns dynamically
- Checkbox column (
showCheckbox, autoCheckHierarchy)
valueAccessor for computed/expression columns
- Column menu (
showColumnMenu)
- Column reorder, resize, auto-fit
- Column templates, column spanning, headers, complex data binding
Sorting
📄 Read: references/sorting.md
- Enable with
allowSorting
- Initial sort via
e-treegrid-sortsettings
- Multi-column sort (CTRL + click)
- Disable sort per column (
allowSorting: false on column)
- Sort events (
actionBegin, actionComplete)
- Programmatic sort/clear via
sortColumn / clearSorting
Filtering
📄 Read: references/filtering.md
- Enable with
allowFiltering
- Filter types: FilterBar (default), Menu, Excel-like
- Filter hierarchy modes: Parent, Child, Both, None
- Initial filter with predicate
- Filter operators (startswith, contains, equal, greaterthan, etc.)
- Disable filter per column
Editing
📄 Read: references/editing.md
- Enable with
e-treegrid-editSettings and isPrimaryKey
- Edit modes: Cell, Row, Dialog, Batch
- Toolbar with Add/Edit/Delete/Update/Cancel
newRowPosition: Top, Bottom, Above, Below, Child
- Delete confirmation dialog
- Default column values on add
- Disable editing per column
- Validation rules
- Persisting edited data to server
Paging
📄 Read: references/paging.md
- Enable with
allowPaging
e-treegrid-pagesettings: pageSize, pageSizeMode (All/Root)
- Page size dropdown, pager template
- Render pager at top via
dataBound event
Selection
📄 Read: references/selection.md
- Row, Cell, Both selection modes
- Single vs Multiple type (
e-treegrid-selectionsettings)
- Checkbox selection with
checkboxMode
- Programmatic selection
Aggregates
📄 Read: references/aggregates.md
- Built-in types: Sum, Average, Min, Max, Count, Truecount, Falsecount
- Footer aggregate and child (parent row footer) aggregate
showChildSummary to show child aggregate
- Custom aggregate function
footerTemplate for custom display
Row Customization
📄 Read: references/row.md
rowDataBound for conditional styling
- Alternate row styling (
.e-altrow)
- Row template, detail template
- Row drag-and-drop (
allowRowDragAndDrop)
- Row height, row spanning
Cell Customization
📄 Read: references/cell.md
queryCellInfo for per-cell customization
- Custom attributes on cells
- Auto text wrap (
allowTextWrap)
- Clip mode (Clip, Ellipsis, EllipsisWithTooltip)
- Grid lines
Export (Excel)
📄 Read: references/excel-export.md
- Excel export (
allowExcelExport, excelExport())
- Persist collapsed state in export
- Custom aggregates in export
- Headers/footers, cell style customization
- Server-side export options
PDF Export
📄 Read: references/pdf-export.md
- PDF export (
allowPdfExport, pdfExport())
- PDF export options and configurations
- Page orientation (Portrait, Landscape)
- Custom headers, footers, and styling
- Cell style customization for PDF
- Server-side PDF export
Print
📄 Read: references/print.md
- Enable printing with
allowPrinting
- Print via toolbar button or external button
- Print current page only (
printMode: 'CurrentPage')
- Show/hide columns during print
- Handling large datasets
- Page setup configuration
Clipboard
📄 Read: references/clipboard.md
- Copy to clipboard with Ctrl+C and Ctrl+Shift+H
- Copy with external buttons
- Copy hierarchy modes (Parent, Child, Both, None)
- AutoFill feature with drag-to-fill
- Paste functionality with Ctrl+V
- Type conversion limitations
Scrolling
📄 Read: references/scrolling.md
- Basic scrolling and responsive configurations
- Sticky header, row/column virtualization, and infinite scrolling
- Performance optimization for large datasets
Adaptive Layout
📄 Read: references/adaptive.md
- Responsive UI with
enableAdaptiveUI for mobile and tablet devices
- Adaptive dialog mode for filtering and editing on small screens
- Expand/collapse behavior optimization for touch interaction
- Column chooser adaptation to mobile dialogs
- Vertical row rendering mode for enhanced mobile readability
- Best practices for responsive TreeGrid design
Frozen Rows and Columns
📄 Read: references/frozen.md
- Freeze rows and columns using
frozenRows, frozenColumns, or isFrozen property
- Freeze direction control with Left/Right positioning
- Limitations and compatibility considerations with other features
Styling and Appearance
📄 Read: references/styling-and-appearance.md
- Customize Tree Grid styling with CSS classes for all elements
- CSS override examples for headers, rows, cells, selection, and summary
- Custom theme options using Syncfusion Theme Studio
Immutable Mode
📄 Read: references/immutable.md
- Enable with
enableImmutableMode="true"
- Performance optimization for large datasets
- Primary key requirement for comparison
- Selective re-render of modified rows
- Performance benefits for batch operations
- Limitations and workarounds
Toolbar
📄 Read: references/toolbar.md
- Built-in toolbar items (Add, Edit, Delete, Update, Cancel, Search, ExcelExport, PdfExport, etc.)
- Custom toolbar items with text, icons, tooltips, and alignment
- Toolbar click handler with event arguments
- Built-in item ID patterns and identification
- Disabling toolbar items dynamically based on row selection
- Best practices for toolbar design and layout
- Edit mode integration with toolbar buttons
Context Menu
📄 Read: references/context-menu.md
- Default context menu items for data manipulation and column operations
- Custom context menu items with hierarchy-aware functionality
- Contextual visibility using target selectors (.e-content, .e-headercell)
- Context menu click handler with row and column information
- Enable/disable items dynamically based on row state (parent/child)
- Hierarchy-aware expand/collapse menus for TreeGrid
- Advanced scenarios: parent-only operations, conditional menu items
- Best practices for TreeGrid-specific context menu design
Searching
📄 Read: references/searching.md
- Enable full-text search across TreeGrid hierarchical data
- Add search toolbar item for real-time filtering as user types
- Configure search field scope (all columns or specific column subset)
- Search with operators (contains, startsWith, endsWith, equal, notEqual)
- Programmatic search triggering from external input controls
- Search in hierarchy with automatic parent row expansion on child matches
- Clear search and reset to show all rows
- Handle search events (actionBegin, actionComplete) for custom logic
- Best practices for searching large hierarchical datasets
Loading Animation
📄 Read: references/loading-animation.md
- Loading indicator types: Spinner (default) and Shimmer animations
- When loading animation displays (initial render, sorting, filtering, paging, searching)
- Remote data binding with loading animation via DataManager
- Programmatic control of loading indicator (show/hide)
- Customizing loading behavior with action events
- Best practices for UX with loading states
- Mobile and slow network optimization
Globalization & Localization
📄 Read: references/global-local.md
- Culture-specific number and date formatting via
locale property
- Localization of UI strings (toolbar, dialogs, pager, filter, expand/collapse text)
- Right-to-left (RTL) layout support for Arabic, Hebrew, and other RTL languages
- CLDR data loading and culture configuration
- Format codes (C2, yMd, N2) for currency, date, and number columns
- Multi-locale support with dynamic language switching
- Best practices for global applications
State Management
📄 Read: references/state-management.md
- Persist TreeGrid state across sessions with
enablePersistence
- Save and restore sorting, filtering, paging, and column preferences
- Preserve expand/collapse state of parent rows on page reload
- LocalStorage-based automatic persistence and manual state retrieval
- Reset TreeGrid state to defaults programmatically
- Custom server-side state persistence for sensitive data
- Best practices for state management in hierarchical data
Accessibility
📄 Read: references/accessibility.md
- WCAG 2.1 compliance
- Keyboard navigation
- ARIA attributes
- Screen reader support
Properties & Configuration
📄 Read: references/properties-configuration.md
- Lookup 145+ TreeGrid properties organized by concern
- Data configuration (dataSource, childMapping, idMapping, parentIdMapping, expandStateMapping)
- UI layout (height, width, rowHeight, treeColumnIndex)
- Grid appearance (gridLines, enableAltRow, enableRtl, enableHover, clipMode)
- Feature toggles table (Paging, Sorting, Filtering, Editing, Selection, etc.)
- Performance tuning (virtualization, infinite scroll, immutable mode, persistence)
- Event callbacks and handlers
- Advanced configuration objects (EditSettings, PageSettings, FilterSettings, SelectionSettings, etc.)
Events & Lifecycle
📄 Read: references/events-methods.md
- Lifecycle events (created, load, dataBound, beforeDataBound, dataSourceChanged)
- Action events (actionBegin, actionComplete, actionFailure)
- Expand/collapse events (expanding, expanded, collapsing, collapsed)
- Edit events (beginEdit, cellEdit, cellSave, cellSaved, batchAdd, batchDelete, beforeBatchSave)
- Selection events (rowSelected, rowSelecting, rowDeselected, checkboxChange)
- Drag & drop events (rowDragStart, rowDrop, columnDragStart, columnDrop)
- Custom rendering events (queryCellInfo, rowDataBound, detailDataBound)
- Export events (beforeExcelExport, excelExportComplete, beforePdfExport, pdfQueryCellInfo)
- Complete event signatures and examples for each category
Settings Classes & Enums Reference
📄 Read: references/classes-enums-reference.md
- Enums: CopyHierarchyType, EditMode, FilterHierarchyMode, FilterType, PageSizeMode, RowPosition, WrapMode
- Settings classes: EditSettings, PageSettings, SortSettings, FilterSettings, SelectionSettings, RowDropSettings, InfiniteScrollSettings
- Column configuration: TreeGridColumn, StackedHeaderCell classes
- Builder pattern for fluent API and tag helper approach
- Complete property definitions for each settings class
Quick Start Example
Minimal TreeGrid with local data, columns, sorting, filtering, and paging:
_ViewImports.cshtml
@addTagHelper *, Syncfusion.EJ2
_Layout.cshtml (inside <head>)
<!-- Syncfusion ASP.NET Core controls styles -->
<link rel="stylesheet" href="~/ej2/ej2version/fluent2.css" />
<!-- Syncfusion ASP.NET Core controls scripts -->
<script src="~/ej2/ej2version/dist/ej2.min.js"></script>
_Layout.cshtml (end of <body>)
<ejs-scripts></ejs-scripts>
Index.cshtml
@{
var data = TreeGridItems.GetTreeData();
}
<ejs-treegrid id="TreeGrid" dataSource="@data" childMapping="Children"
treeColumnIndex="1" allowSorting="true" allowFiltering="true" allowPaging="true">
<e-treegrid-pagesettings pageSize="5"></e-treegrid-pagesettings>
<e-treegrid-columns>
<e-treegrid-column field="TaskId" headerText="Task ID" isPrimaryKey="true"
textAlign="Right" width="95"></e-treegrid-column>
<e-treegrid-column field="TaskName" headerText="Task Name" width="220"></e-treegrid-column>
<e-treegrid-column field="StartDate" headerText="Start Date"
textAlign="Right" format="yMd" type="date" width="115"></e-treegrid-column>
<e-treegrid-column field="Duration" headerText="Duration"
textAlign="Right" width="100"></e-treegrid-column>
</e-treegrid-columns>
</ejs-treegrid>
Index.cshtml.cs (or Controller)
public class TreeGridItems
{
public int TaskId { get; set; }
public string TaskName { get; set; }
public DateTime StartDate { get; set; }
public int Duration { get; set; }
public List<TreeGridItems> Children { get; set; }
public static List<TreeGridItems> GetTreeData()
{
return new List<TreeGridItems>
{
new TreeGridItems
{
TaskId = 1, TaskName = "Planning",
StartDate = new DateTime(2021, 6, 7), Duration = 5,
Children = new List<TreeGridItems>
{
new TreeGridItems { TaskId = 2, TaskName = "Plan timeline", StartDate = new DateTime(2021, 6, 7), Duration = 5 },
new TreeGridItems { TaskId = 3, TaskName = "Plan budget", StartDate = new DateTime(2021, 6, 7), Duration = 5 }
}
}
};
}
}
Common Patterns
When to use childMapping vs idMapping
childMapping: Data is nested (each parent has a Children list) → bind childMapping="Children"
idMapping + parentIdMapping: Data is flat with parent ID references → bind idMapping="TaskId" parentIdMapping="ParentId"
Enable Editing with Toolbar
<ejs-treegrid id="TreeGrid" dataSource="@data" childMapping="Children"
treeColumnIndex="1" toolbar="@(new List<string>() {"Add","Edit","Delete","Update","Cancel"})">
<e-treegrid-editsettings allowAdding="true" allowEditing="true"
allowDeleting="true" mode="Row"></e-treegrid-editsettings>
<e-treegrid-columns>
<e-treegrid-column field="TaskId" headerText="Task ID"
isPrimaryKey="true" width="90"></e-treegrid-column>
<e-treegrid-column field="TaskName" headerText="Task Name" width="220"></e-treegrid-column>
</e-treegrid-columns>
</ejs-treegrid>
Always set isPrimaryKey="true" on one column — editing and delete operations require it.
Key Error Avoidance
- Do NOT enable paging and virtualization simultaneously
- Do NOT set
isFrozen and frozenColumns at the same time
showCheckbox column must be defined only on the tree column
textAlign="Right" is not applicable for the tree column
- Do NOT enable
idMapping and childMapping simultaneously
1---2name: syncfusion-aspnetcore-tree-grid3description: Implements Syncfusion ASP.NET Core TreeGrid for hierarchical data with sorting, filtering, editing, exporting, paging, virtual scrolling, and advanced features. Supports configuration, CRUD, aggregates, templates, state persistence, and performance optimization in ASP.NET Core applications.4---56# Syncfusion ASP.NET Core TreeGrid78The TreeGrid component visualizes self-referential hierarchical data in a tabular format. It supports child/parent data binding (via `childMapping` or `idMapping`), expand/collapse of child rows, sorting, filtering, editing, paging, export, and virtualization.910## ⚠️ Security & Trust Boundary11 12- The TreeGrid skill does not perform any remote data access.13- All external API interaction is handled by a separate DataManager skill outside this skill’s trust boundary.1415## When to Use This Skill1617- Rendering hierarchical or parent-child structured data in ASP.NET Core (e.g. project tasks, org charts, bill of materials)18- Implementing CRUD operations on tree-structured data19- Sorting, filtering, or searching across hierarchical records20- Exporting tree data to Excel or PDF21- Handling large datasets with virtual scrolling or infinite scroll2223> Refer to [**Properties & Configuration**](#properties--configuration), [**Events & Lifecycle**](#events--lifecycle), and [**Classes & Enums Reference**](#settings-classes--enums-reference) files for complete API lookup.2425## Table of Contents26- [Data Structure Rules](#data-structure-rules)27- [Documentation and Navigation Guide](#documentation-and-navigation-guide)28- [Quick Start Example](#quick-start-example)29- [Common Patterns](#common-patterns)3031## Data Structure Rules3233### Rule 1: childMapping is MANDATORY for Hierarchical Data34**Severity**: 🔴 CRITICAL - Grid will not expand/collapse without this3536**Requirement**:3738**CSHTML View**:39```cshtml40<!-- ✅ REQUIRED - childMapping matches data property name exactly -->41<ejs-treegrid id="TreeGrid" dataSource="@ViewBag.data" childMapping="Children"42 treeColumnIndex="1" allowPaging="true">43 <e-treegrid-columns>44 <e-treegrid-column field="TaskId" headerText="Task ID" 45 isPrimaryKey="true" textAlign="Right" width="95"></e-treegrid-column>46 <e-treegrid-column field="TaskName" headerText="Task Name" width="220"></e-treegrid-column>47 <e-treegrid-column field="Duration" headerText="Duration" textAlign="Right" width="100"></e-treegrid-column>48 </e-treegrid-columns>49</ejs-treegrid>5051<!-- ❌ WRONG - No childMapping = No expansion possible -->52<ejs-treegrid id="TreeGrid2" dataSource="@ViewBag.data">53 <!-- Missing childMapping & treeColumnIndex - Won't expand! -->54</ejs-treegrid>55```5657**Data Format C# Model**:58```csharp59public class TreeGridItem60{61 public int TaskId { get; set; }62 public string TaskName { get; set; }63 public int Duration { get; set; }64 public List<TreeGridItem> Children { get; set; } // Must match childMapping="Children"65}6667// Sample data68var data = new List<TreeGridItem>69{70 new TreeGridItem71 {72 TaskId = 1,73 TaskName = "Planning",74 Duration = 5,75 Children = new List<TreeGridItem> // ✅ CORRECT - nested Children property76 {77 new TreeGridItem { TaskId = 2, TaskName = "Identify Site", Duration = 2 },78 new TreeGridItem { TaskId = 3, TaskName = "Perform Test", Duration = 3 }79 }80 }81};82```8384**Alternative: Flat Structure with Parent IDs**:85```cshtml86<!-- Use idMapping + parentIdMapping instead of childMapping -->87<ejs-treegrid id="TreeGrid" dataSource="@ViewBag.flatData" 88 idMapping="TaskId" parentIdMapping="ParentId" treeColumnIndex="1">89 ...90</ejs-treegrid>91```9293```csharp94var flatData = new List<TreeGridItem>95{96 new TreeGridItem { TaskId = 1, TaskName = "Planning", ParentId = null },97 new TreeGridItem { TaskId = 2, TaskName = "Identify Site", ParentId = 1 },98 new TreeGridItem { TaskId = 3, TaskName = "Perform Test", ParentId = 1 }99};100```101102### Rule 2: Data Type Matching is MANDATORY103**Severity**: 🟠 IMPORTANT - Type mismatches cause rendering/sorting issues104105**C# Model - Correct Types**:106```csharp107public class TreeGridItem108{109 public int TaskId { get; set; } // ✅ int type110 public string TaskName { get; set; } // ✅ string type111 public DateTime StartDate { get; set; } // ✅ DateTime for date columns112 public decimal Price { get; set; } // ✅ decimal for currency113}114115var data = new List<TreeGridItem>116{117 new TreeGridItem118 {119 TaskId = 1, // int, not string "1"120 TaskName = "Planning",121 StartDate = new DateTime(2024, 3, 15), // DateTime, not "03/15/2024"122 Price = 1500.50m // decimal, not string "1500.50"123 }124};125```126127**CSHTML Column Definition - Match Data Types**:128```cshtml129<ejs-treegrid id="TreeGrid" dataSource="@ViewBag.data" childMapping="Children">130 <e-treegrid-columns>131 <!-- field "TaskId" is int, so type="number" -->132 <e-treegrid-column field="TaskId" headerText="Task ID" 133 type="number" textAlign="Right" width="95"></e-treegrid-column>134 <!-- field "TaskName" is string, type="string" (default) -->135 <e-treegrid-column field="TaskName" headerText="Task Name" width="220"></e-treegrid-column>136 <!-- field "StartDate" is DateTime, so type="date" with format -->137 <e-treegrid-column field="StartDate" headerText="Start Date" 138 type="date" format="yMd" textAlign="Right" width="115"></e-treegrid-column>139 <!-- field "Price" is decimal, type="number" with currency format -->140 <e-treegrid-column field="Price" headerText="Price" 141 type="number" format="c2" textAlign="Right" width="100"></e-treegrid-column>142 </e-treegrid-columns>143</ejs-treegrid>144```145146**❌ WRONG - Type Mismatch Issues**:147```csharp148// Bad model - mixing string where types should be specific149var badData = new List<TreeGridItem>150{151 new TreeGridItem152 {153 TaskId = "1", // ❌ String instead of int154 StartDate = "02/03/2024" // ❌ String instead of DateTime155 }156};157// Result: Sorting fails, formatting doesn't work, expand/collapse issues158```159160## Documentation and Navigation Guide161162### Getting Started163📄 **Read:** [references/getting-started.md](references/getting-started.md)164- NuGet installation (`Syncfusion.EJ2.AspNet.Core`)165- TagHelper registration in `_ViewImports.cshtml`166- CSS/script CDN setup in `_Layout.cshtml`167- Basic `<ejs-treegrid>` declaration168- Binding local data with `childMapping` / `treeColumnIndex`169- Defining columns with `<e-treegrid-columns>`170- Enabling paging, sorting, and filtering at startup171- Error handling with `actionFailure`172173### Data Binding174📄 **Read:** [references/data-binding.md](references/data-binding.md)175- Local data with `childMapping` (nested list) and `idMapping`/`parentIdMapping` (flat list)176- Remote data via `DataManager` with OData/WebAPI adaptor177- Ajax/Fetch-based binding178- `expandStateMapping` — control initial expand/collapse state per row179- Handling null or missing parent references180181### Columns182📄 **Read:** [references/columns.md](references/columns.md)183- Column `field`, `headerText`, `textAlign`, `width`, `type`, `format`184- `treeColumnIndex` — which column shows expand/collapse arrows185- Number/date formatting (N2, C2, yMd, custom)186- Lock columns, show/hide columns dynamically187- Checkbox column (`showCheckbox`, `autoCheckHierarchy`)188- `valueAccessor` for computed/expression columns189- Column menu (`showColumnMenu`)190- Column reorder, resize, auto-fit191- Column templates, column spanning, headers, complex data binding192193### Sorting194📄 **Read:** [references/sorting.md](references/sorting.md)195- Enable with `allowSorting`196- Initial sort via `e-treegrid-sortsettings`197- Multi-column sort (CTRL + click)198- Disable sort per column (`allowSorting: false` on column)199- Sort events (`actionBegin`, `actionComplete`)200- Programmatic sort/clear via `sortColumn` / `clearSorting`201202### Filtering203📄 **Read:** [references/filtering.md](references/filtering.md)204- Enable with `allowFiltering`205- Filter types: FilterBar (default), Menu, Excel-like206- Filter hierarchy modes: Parent, Child, Both, None207- Initial filter with predicate208- Filter operators (startswith, contains, equal, greaterthan, etc.)209- Disable filter per column210211### Editing212📄 **Read:** [references/editing.md](references/editing.md)213- Enable with `e-treegrid-editSettings` and `isPrimaryKey`214- Edit modes: Cell, Row, Dialog, Batch215- Toolbar with Add/Edit/Delete/Update/Cancel216- `newRowPosition`: Top, Bottom, Above, Below, Child217- Delete confirmation dialog218- Default column values on add219- Disable editing per column220- Validation rules221- Persisting edited data to server222223### Paging224📄 **Read:** [references/paging.md](references/paging.md)225- Enable with `allowPaging`226- `e-treegrid-pagesettings`: `pageSize`, `pageSizeMode` (All/Root)227- Page size dropdown, pager template228- Render pager at top via `dataBound` event229230### Selection231📄 **Read:** [references/selection.md](references/selection.md)232- Row, Cell, Both selection modes233- Single vs Multiple type (`e-treegrid-selectionsettings`)234- Checkbox selection with `checkboxMode`235- Programmatic selection236237### Aggregates238📄 **Read:** [references/aggregates.md](references/aggregates.md)239- Built-in types: Sum, Average, Min, Max, Count, Truecount, Falsecount240- Footer aggregate and child (parent row footer) aggregate241- `showChildSummary` to show child aggregate242- Custom aggregate function243- `footerTemplate` for custom display244245### Row Customization246📄 **Read:** [references/row.md](references/row.md)247- `rowDataBound` for conditional styling248- Alternate row styling (`.e-altrow`)249- Row template, detail template250- Row drag-and-drop (`allowRowDragAndDrop`)251- Row height, row spanning252253### Cell Customization254📄 **Read:** [references/cell.md](references/cell.md)255- `queryCellInfo` for per-cell customization256- Custom attributes on cells257- Auto text wrap (`allowTextWrap`)258- Clip mode (Clip, Ellipsis, EllipsisWithTooltip)259- Grid lines260261### Export (Excel)262📄 **Read:** [references/excel-export.md](references/excel-export.md)263- Excel export (`allowExcelExport`, `excelExport()`)264- Persist collapsed state in export265- Custom aggregates in export266- Headers/footers, cell style customization267- Server-side export options268269### PDF Export270📄 **Read:** [references/pdf-export.md](references/pdf-export.md)271- PDF export (`allowPdfExport`, `pdfExport()`)272- PDF export options and configurations273- Page orientation (Portrait, Landscape)274- Custom headers, footers, and styling275- Cell style customization for PDF276- Server-side PDF export277278### Print279📄 **Read:** [references/print.md](references/print.md)280- Enable printing with `allowPrinting`281- Print via toolbar button or external button282- Print current page only (`printMode: 'CurrentPage'`)283- Show/hide columns during print284- Handling large datasets285- Page setup configuration286287### Clipboard288📄 **Read:** [references/clipboard.md](references/clipboard.md)289- Copy to clipboard with Ctrl+C and Ctrl+Shift+H290- Copy with external buttons291- Copy hierarchy modes (Parent, Child, Both, None)292- AutoFill feature with drag-to-fill293- Paste functionality with Ctrl+V294- Type conversion limitations295296### Scrolling297📄 **Read:** [references/scrolling.md](references/scrolling.md)298- Basic scrolling and responsive configurations299- Sticky header, row/column virtualization, and infinite scrolling300- Performance optimization for large datasets301302### Adaptive Layout303📄 **Read:** [references/adaptive.md](references/adaptive.md)304- Responsive UI with `enableAdaptiveUI` for mobile and tablet devices305- Adaptive dialog mode for filtering and editing on small screens306- Expand/collapse behavior optimization for touch interaction307- Column chooser adaptation to mobile dialogs308- Vertical row rendering mode for enhanced mobile readability309- Best practices for responsive TreeGrid design310311### Frozen Rows and Columns312📄 **Read:** [references/frozen.md](references/frozen.md)313- Freeze rows and columns using `frozenRows`, `frozenColumns`, or `isFrozen` property314- Freeze direction control with Left/Right positioning315- Limitations and compatibility considerations with other features316317### Styling and Appearance318📄 **Read:** [references/styling-and-appearance.md](references/styling-and-appearance.md)319- Customize Tree Grid styling with CSS classes for all elements320- CSS override examples for headers, rows, cells, selection, and summary321- Custom theme options using Syncfusion Theme Studio322323### Immutable Mode324📄 **Read:** [references/immutable.md](references/immutable.md)325- Enable with `enableImmutableMode="true"`326- Performance optimization for large datasets327- Primary key requirement for comparison328- Selective re-render of modified rows329- Performance benefits for batch operations330- Limitations and workarounds331332### Toolbar333📄 **Read:** [references/toolbar.md](references/toolbar.md)334- Built-in toolbar items (Add, Edit, Delete, Update, Cancel, Search, ExcelExport, PdfExport, etc.)335- Custom toolbar items with text, icons, tooltips, and alignment336- Toolbar click handler with event arguments337- Built-in item ID patterns and identification338- Disabling toolbar items dynamically based on row selection339- Best practices for toolbar design and layout340- Edit mode integration with toolbar buttons341342### Context Menu343📄 **Read:** [references/context-menu.md](references/context-menu.md)344- Default context menu items for data manipulation and column operations345- Custom context menu items with hierarchy-aware functionality346- Contextual visibility using target selectors (.e-content, .e-headercell)347- Context menu click handler with row and column information348- Enable/disable items dynamically based on row state (parent/child)349- Hierarchy-aware expand/collapse menus for TreeGrid350- Advanced scenarios: parent-only operations, conditional menu items351- Best practices for TreeGrid-specific context menu design352353### Searching354📄 **Read:** [references/searching.md](references/searching.md)355- Enable full-text search across TreeGrid hierarchical data356- Add search toolbar item for real-time filtering as user types357- Configure search field scope (all columns or specific column subset)358- Search with operators (contains, startsWith, endsWith, equal, notEqual)359- Programmatic search triggering from external input controls360- Search in hierarchy with automatic parent row expansion on child matches361- Clear search and reset to show all rows362- Handle search events (actionBegin, actionComplete) for custom logic363- Best practices for searching large hierarchical datasets364365### Loading Animation366📄 **Read:** [references/loading-animation.md](references/loading-animation.md)367- Loading indicator types: Spinner (default) and Shimmer animations368- When loading animation displays (initial render, sorting, filtering, paging, searching)369- Remote data binding with loading animation via DataManager370- Programmatic control of loading indicator (show/hide)371- Customizing loading behavior with action events372- Best practices for UX with loading states373- Mobile and slow network optimization374375### Globalization & Localization376📄 **Read:** [references/global-local.md](references/global-local.md)377- Culture-specific number and date formatting via `locale` property378- Localization of UI strings (toolbar, dialogs, pager, filter, expand/collapse text)379- Right-to-left (RTL) layout support for Arabic, Hebrew, and other RTL languages380- CLDR data loading and culture configuration381- Format codes (C2, yMd, N2) for currency, date, and number columns382- Multi-locale support with dynamic language switching383- Best practices for global applications384385### State Management386📄 **Read:** [references/state-management.md](references/state-management.md)387- Persist TreeGrid state across sessions with `enablePersistence`388- Save and restore sorting, filtering, paging, and column preferences389- Preserve expand/collapse state of parent rows on page reload390- LocalStorage-based automatic persistence and manual state retrieval391- Reset TreeGrid state to defaults programmatically392- Custom server-side state persistence for sensitive data393- Best practices for state management in hierarchical data394395### Accessibility396📄 **Read:** [references/accessibility.md](references/accessibility.md)397- WCAG 2.1 compliance398- Keyboard navigation399- ARIA attributes400- Screen reader support401402### Properties & Configuration403📄 **Read:** [references/properties-configuration.md](references/properties-configuration.md)404- Lookup 145+ TreeGrid properties organized by concern405- Data configuration (dataSource, childMapping, idMapping, parentIdMapping, expandStateMapping)406- UI layout (height, width, rowHeight, treeColumnIndex)407- Grid appearance (gridLines, enableAltRow, enableRtl, enableHover, clipMode)408- Feature toggles table (Paging, Sorting, Filtering, Editing, Selection, etc.)409- Performance tuning (virtualization, infinite scroll, immutable mode, persistence)410- Event callbacks and handlers411- Advanced configuration objects (EditSettings, PageSettings, FilterSettings, SelectionSettings, etc.)412413### Events & Lifecycle414📄 **Read:** [references/events-methods.md](references/events-methods.md)415- Lifecycle events (created, load, dataBound, beforeDataBound, dataSourceChanged)416- Action events (actionBegin, actionComplete, actionFailure)417- Expand/collapse events (expanding, expanded, collapsing, collapsed)418- Edit events (beginEdit, cellEdit, cellSave, cellSaved, batchAdd, batchDelete, beforeBatchSave)419- Selection events (rowSelected, rowSelecting, rowDeselected, checkboxChange)420- Drag & drop events (rowDragStart, rowDrop, columnDragStart, columnDrop)421- Custom rendering events (queryCellInfo, rowDataBound, detailDataBound)422- Export events (beforeExcelExport, excelExportComplete, beforePdfExport, pdfQueryCellInfo)423- Complete event signatures and examples for each category424425### Settings Classes & Enums Reference426📄 **Read:** [references/classes-enums-reference.md](references/classes-enums-reference.md)427- Enums: CopyHierarchyType, EditMode, FilterHierarchyMode, FilterType, PageSizeMode, RowPosition, WrapMode428- Settings classes: EditSettings, PageSettings, SortSettings, FilterSettings, SelectionSettings, RowDropSettings, InfiniteScrollSettings429- Column configuration: TreeGridColumn, StackedHeaderCell classes430- Builder pattern for fluent API and tag helper approach431- Complete property definitions for each settings class432433## Quick Start Example434435**Minimal TreeGrid with local data, columns, sorting, filtering, and paging:**436437**`_ViewImports.cshtml`**438```cshtml439@addTagHelper *, Syncfusion.EJ2440```441442**`_Layout.cshtml`** (inside `<head>`)443```cshtml444<!-- Syncfusion ASP.NET Core controls styles -->445<link rel="stylesheet" href="~/ej2/ej2version/fluent2.css" />446<!-- Syncfusion ASP.NET Core controls scripts -->447<script src="~/ej2/ej2version/dist/ej2.min.js"></script>448```449450**`_Layout.cshtml`** (end of `<body>`)451```cshtml452<ejs-scripts></ejs-scripts>453```454455**`Index.cshtml`**456```cshtml457@{458 var data = TreeGridItems.GetTreeData();459}460461<ejs-treegrid id="TreeGrid" dataSource="@data" childMapping="Children"462 treeColumnIndex="1" allowSorting="true" allowFiltering="true" allowPaging="true">463 <e-treegrid-pagesettings pageSize="5"></e-treegrid-pagesettings>464 <e-treegrid-columns>465 <e-treegrid-column field="TaskId" headerText="Task ID" isPrimaryKey="true"466 textAlign="Right" width="95"></e-treegrid-column>467 <e-treegrid-column field="TaskName" headerText="Task Name" width="220"></e-treegrid-column>468 <e-treegrid-column field="StartDate" headerText="Start Date"469 textAlign="Right" format="yMd" type="date" width="115"></e-treegrid-column>470 <e-treegrid-column field="Duration" headerText="Duration"471 textAlign="Right" width="100"></e-treegrid-column>472 </e-treegrid-columns>473</ejs-treegrid>474```475476**`Index.cshtml.cs` (or Controller)**477```csharp478public class TreeGridItems479{480 public int TaskId { get; set; }481 public string TaskName { get; set; }482 public DateTime StartDate { get; set; }483 public int Duration { get; set; }484 public List<TreeGridItems> Children { get; set; }485486 public static List<TreeGridItems> GetTreeData()487 {488 return new List<TreeGridItems>489 {490 new TreeGridItems491 {492 TaskId = 1, TaskName = "Planning",493 StartDate = new DateTime(2021, 6, 7), Duration = 5,494 Children = new List<TreeGridItems>495 {496 new TreeGridItems { TaskId = 2, TaskName = "Plan timeline", StartDate = new DateTime(2021, 6, 7), Duration = 5 },497 new TreeGridItems { TaskId = 3, TaskName = "Plan budget", StartDate = new DateTime(2021, 6, 7), Duration = 5 }498 }499 }500 };501 }502}503```504505## Common Patterns506507### When to use `childMapping` vs `idMapping`508- **`childMapping`**: Data is nested (each parent has a `Children` list) → bind `childMapping="Children"`509- **`idMapping` + `parentIdMapping`**: Data is flat with parent ID references → bind `idMapping="TaskId" parentIdMapping="ParentId"`510511### Enable Editing with Toolbar512```cshtml513<ejs-treegrid id="TreeGrid" dataSource="@data" childMapping="Children"514 treeColumnIndex="1" toolbar="@(new List<string>() {"Add","Edit","Delete","Update","Cancel"})">515 <e-treegrid-editsettings allowAdding="true" allowEditing="true"516 allowDeleting="true" mode="Row"></e-treegrid-editsettings>517 <e-treegrid-columns>518 <e-treegrid-column field="TaskId" headerText="Task ID"519 isPrimaryKey="true" width="90"></e-treegrid-column>520 <e-treegrid-column field="TaskName" headerText="Task Name" width="220"></e-treegrid-column>521 </e-treegrid-columns>522</ejs-treegrid>523```524525> Always set `isPrimaryKey="true"` on one column — editing and delete operations require it.526527### Key Error Avoidance528- Do NOT enable paging and virtualization simultaneously529- Do NOT set `isFrozen` and `frozenColumns` at the same time530- `showCheckbox` column must be defined only on the tree column531- `textAlign="Right"` is not applicable for the tree column532- Do NOT enable `idMapping` and `childMapping` simultaneously