Skip to content

About

Sample demonstrating how to bind the Syncfusion Blazor TreeView component to a SQL Server database using Entity Framework Core, a Web API controller and SfDataManager with WebApiAdaptor, with CRUD operations (add, edit, delete) through a context menu and load on demand.

Topics

Resources

Stars

1 star

Watchers

5 watching

Forks

Latest commit

 

History

27 Commits

Folders and files

Repository files navigation

Blazor TreeView Entity Framework Integration

Overview

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.

Key Features

  • Uses SfTreeView to display hierarchical data.
  • Uses SfContextMenu to 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.

Prerequisites

How to Run the Project

Visual Studio 2022

  1. Clone or download this repository.

  2. Open the solution file:

    SQLTreeView.sln

  3. Restore all NuGet packages.

  4. Set the startup project to:

    SQLTreeView

  5. By default, the sample attaches SQLTreeView/App_Data/NORTHWND.MDF to SQL Server LocalDB, so no path change is needed. To use another SQL Server, set the TreeViewConnectionString environment variable, or update the connection string in the following file:

    SQLTreeView/DataAccess/OrganizationContext.cs

  6. Build the solution.

  7. Run the application using Ctrl+F5.

  8. Open the application URL displayed by Visual Studio after launch.

Visual Studio Code

  1. Open the repository folder in Visual Studio Code.

  2. Open the integrated terminal.

  3. Navigate to the Blazor Web App (server) project directory.

    cd SQLTreeView
  4. Ensure the referenced SQL Server database is available. To use a different SQL Server instead of LocalDB, set the TreeViewConnectionString environment variable, or update the connection string in the following file:

    SQLTreeView/DataAccess/OrganizationContext.cs

  5. Restore NuGet packages.

    dotnet restore
  6. Run the project.

    dotnet run
  7. Open the local application URL displayed in the terminal after the application starts.

Support and Feedback

License

This is a Syncfusion sample project provided to demonstrate product usage. Review the Syncfusion license terms before using Syncfusion components in your own applications.

About

Sample demonstrating how to bind the Syncfusion Blazor TreeView component to a SQL Server database using Entity Framework Core, a Web API controller and SfDataManager with WebApiAdaptor, with CRUD operations (add, edit, delete) through a context menu and load on demand.

Topics

Resources

Stars

1 star

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages