This sample is a Blazor Web App with interactive WebAssembly render mode (.NET 10). It demonstrates how to populate a Syncfusion Blazor TreeView using data stored in a SQL Server database and accessed through Entity Framework. The application uses a database-backed hierarchical data source to render nodes in the TreeView component, allowing developers to manage and display relational data in a structured tree format. The sample is useful for applications that require navigation structures, category hierarchies, organizational trees, or database-driven parent-child relationships.
- Uses
SfTreeViewto display hierarchical data. - Uses
SfContextMenuto expose node editing actions. - Handles node interactions through
NodeClickEventArgs. - Retrieves the next available record identifier from
api/Default/index. - Uses
tree.AddNodes()to dynamically create child nodes. - Uses
tree.RemoveNodes()to delete selected nodes. - Uses
tree.BeginEdit()to rename existing nodes. - Maintains selected node information through the TreeView node UID.
- Demonstrates integration between Blazor UI components and Entity Framework-backed data services.
- Supports hierarchical parent-child record relationships.
- Visual Studio 2022 (version 17.14 or later) or Visual Studio Code
- .NET 10 SDK
- SQL Server LocalDB (or any SQL Server instance, see the database note below)
- Entity Framework Core
- Syncfusion Blazor components
- The sample database
NORTHWND.MDFis included inSQLTreeView/App_Data
Visual Studio 2022
-
Clone or download this repository.
-
Open the solution file:
SQLTreeView.sln -
Restore all NuGet packages.
-
Set the startup project to:
SQLTreeView -
By default, the sample attaches
SQLTreeView/App_Data/NORTHWND.MDFto SQL Server LocalDB, so no path change is needed. To use another SQL Server, set theTreeViewConnectionStringenvironment variable, or update the connection string in the following file:SQLTreeView/DataAccess/OrganizationContext.cs -
Build the solution.
-
Run the application using
Ctrl+F5. -
Open the application URL displayed by Visual Studio after launch.
Visual Studio Code
-
Open the repository folder in Visual Studio Code.
-
Open the integrated terminal.
-
Navigate to the Blazor Web App (server) project directory.
cd SQLTreeView -
Ensure the referenced SQL Server database is available. To use a different SQL Server instead of LocalDB, set the
TreeViewConnectionStringenvironment variable, or update the connection string in the following file:SQLTreeView/DataAccess/OrganizationContext.cs -
Restore NuGet packages.
dotnet restore
-
Run the project.
dotnet run
-
Open the local application URL displayed in the terminal after the application starts.
- For general product questions, visit the Syncfusion Community Forum or Syncfusion Support.
- To report an issue specific to this sample, open a GitHub issue in this repository.
- Official documentation: https://blazor.syncfusion.com/documentation/treeview/getting-started
This is a Syncfusion sample project provided to demonstrate product usage. Review the Syncfusion license terms before using Syncfusion components in your own applications.