Getting Started with Blazor Kanban Component in Blazor Server App

18 Nov 20188 minutes to read

This section briefly explains about how to include Blazor Kanban component in a Blazor Server App using Visual Studio, Visual Studio Code, and the .NET CLI.

Prerequisites

Create a new Blazor App in Visual Studio

Create a Blazor Server App by using the Blazor Web App template in Visual Studio via Microsoft Templates or the Syncfusion® Blazor Extension. For detailed instructions, refer to the Blazor Server App Getting Started documentation.

Install required Blazor packages

Install Syncfusion.Blazor.Kanban and Syncfusion.Blazor.Themes using Visual Studio’s NuGet Package Manager (Tools → NuGet Package Manager → Manage NuGet Packages for Solution).

Alternatively, use the Package Manager Console:

Install-Package Syncfusion.Blazor.Kanban -Version 34.1.29
Install-Package Syncfusion.Blazor.Themes -Version 34.1.29

NOTE

All Syncfusion Blazor packages are available on nuget.org. See the NuGet packages topic for details.

Prerequisites

Create a new Blazor App in Visual Studio Code

Create a Blazor Server App using Visual Studio Code via Microsoft Templates or the Syncfusion® Blazor Extension. For detailed instructions, refer to the Blazor Server App Getting Started documentation.

Alternatively, create a Server application by using the following command in the integrated terminal (Ctrl+`).

dotnet new blazor -o BlazorApp -int Server
cd BlazorApp

Install required Blazor packages

From the integrated terminal, add the required packages of Syncfusion.Blazor.Kanban and Syncfusion.Blazor.Themes to the project:

dotnet add package Syncfusion.Blazor.Kanban --version 34.1.29
dotnet add package Syncfusion.Blazor.Themes --version 34.1.29

NOTE

All Syncfusion Blazor packages are available on nuget.org. See the NuGet packages topic for details.

Prerequisites

Install the latest version of .NET SDK. If the .NET SDK is already installed, determine the installed version by running the following command in a command prompt (Windows), terminal (macOS), or command shell (Linux).

dotnet --version

Create a Blazor Server App using .NET CLI

Run the following command to create a new Blazor Server App in a command prompt (Windows) or terminal (macOS) or command shell (Linux). For detailed instructions, refer to the Blazor Server App Getting Started documentation.

dotnet new blazor -o BlazorApp -int Server
cd BlazorApp

Install required Blazor packages

Run the following commands to add the packages of Syncfusion.Blazor.Kanban and Syncfusion.Blazor.Themes:

dotnet add package Syncfusion.Blazor.Kanban --version 34.1.29
dotnet add package Syncfusion.Blazor.Themes --version 34.1.29

NOTE

All Syncfusion Blazor packages are available on nuget.org. See the NuGet packages topic for details.

NOTE

Configure the appropriate Interactive render mode and Interactivity location while creating a Blazor Server App. For detailed information, refer to the interactive render mode documentation.

Register Blazor service

Register the Blazor service in the Program.cs file of your Blazor Server App.

....
using Syncfusion.Blazor;
....
builder.Services.AddSyncfusionBlazor();
....

Add stylesheet and script resources

The theme stylesheet and script can be accessed from NuGet through Static Web Assets. Include the stylesheet and script references in the ~/Components/App.razor file.

  • Add the stylesheet reference inside the <head> tag of the App.razor file.
  • Add the script reference inside the <body> tag of the App.razor file.
<link href="_content/Syncfusion.Blazor.Themes/fluent2.css" rel="stylesheet" />
....
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js" type="text/javascript"></script>

NOTE

Check out the Blazor Themes topic to discover various methods (Static Web Assets, CDN, and CRG) for referencing themes in Blazor application. Also, check out the Adding Script Reference topic to learn different approaches for adding script references in Blazor application.

Add Blazor Kanban component

Add the Blazor Kanban component in the ~/Components/Pages/Home.razor file. If the interactivity location is set to Per page/component, define a render mode at the top of the ~Pages/Home.razor file.

NOTE

If the Interactivity Location is set to Global, the render mode is automatically configured in the App.razor file by default.

@* desired render mode define here *@
@rendermode InteractiveServer
@using Syncfusion.Blazor.Kanban

<SfKanban TValue="TasksModel" KeyField="Status" DataSource="Tasks">
    <KanbanColumns>
        <KanbanColumn HeaderText="To Do" KeyField="@(new List<string>() {"Open"})"></KanbanColumn>
        <KanbanColumn HeaderText="In Progress" KeyField="@(new List<string>() {"InProgress"})"></KanbanColumn>
        <KanbanColumn HeaderText="Testing" KeyField="@(new List<string>() {"Testing"})"></KanbanColumn>
        <KanbanColumn HeaderText="Done" KeyField="@(new List<string>() {"Close"})"></KanbanColumn>
    </KanbanColumns>
    <KanbanCardSettings HeaderField="Title" ContentField="Summary"></KanbanCardSettings>
</SfKanban>

@code {
    public class TasksModel
    {
        public string? Id { get; set; }
        public string? Title { get; set; }
        public string? Status { get; set; }
        public string? Summary { get; set; }
    }

    public List<TasksModel> Tasks = new List<TasksModel>()
    {
        new TasksModel { Id = "Task 1", Title = "BLAZ-29001", Status = "Open", Summary = "Analyze the new requirements gathered from the customer." },
        new TasksModel { Id = "Task 2", Title = "BLAZ-29002", Status = "Open", Summary = "Show the retrieved data from the server in grid control." },
        new TasksModel { Id = "Task 3", Title = "BLAZ-29003", Status = "InProgress", Summary = "Improve application performance" },
        new TasksModel { Id = "Task 4", Title = "BLAZ-29004", Status = "Testing", Summary = "Fix the issues reported by the customer." },
        new TasksModel { Id = "Task 5", Title = "BLAZ-29005", Status = "Testing", Summary = "Fix the issues reported in Safari browser." },
        new TasksModel { Id = "Task 6", Title = "BLAZ-29006", Status = "Close", Summary = "Analyze SQL server 2008 connection." },
        new TasksModel { Id = "Task 7", Title = "BLAZ-29007", Status = "Close", Summary = "Analyze grid control." },
        new TasksModel { Id = "Task 8", Title = "BLAZ-29008", Status = "Close", Summary = "Stored procedure for initial data binding of the grid." }
    };
}

Run the application

Visual Studio:

  • Press Ctrl+F5 (Windows) or +F5 (macOS) to launch the application. The Blazor Gantt Chart component will render in your default web browser.

Visual Studio Code or .NET CLI:

  1. Open a terminal in the project directory and run the following command:
     dotnet run
    
  2. The application will start and display in your default web browser.

NOTE

You can also explore our Blazor Kanban Board example that shows you how to render and configure the Kanban Board.

See also

  1. Getting Started with Blazor for client-side in .NET Core CLI
  2. Getting Started with Blazor for client-side in Visual Studio