Example of Swimlane Template in ASP.NET MVC Kanban Control
This sample demonstrates swimlane template customization in the Kanban component, enabling workflow items to be organized and presented with personalized swimlane headers for improved task visualization.
${Text}${Text}
<template id="kanban-swimlane-template"><span class="kanban-swimlane-avatar">${Text}</span><span class="kanban-swimlane-name">${Text}</span></template>
@Html.UiKanban(new UiKanbanOptions
{
Id = "swimlaneTemplateBoard",
DataSource = (IEnumerable<object>)ViewData["DataSource"],
KeyField = "Status",
CardSettings = new UiKanbanCardSettings { HeaderField = "Id", ContentField = "Summary", TagsField = "Tags", GrabberField = "Cls" },
Columns = new List<UiKanbanColumn>
{
new UiKanbanColumn { KeyField = "Open", HeaderText = "To Do" },
new UiKanbanColumn { KeyField = "InProgress", HeaderText = "In Progress" },
new UiKanbanColumn { KeyField = "Testing, Validate", HeaderText = "In Review" },
new UiKanbanColumn { KeyField = "Close", HeaderText = "Done" }
},
SwimlaneSettings = new UiKanbanSwimlaneSettings { KeyField = "Assignee", Template = "#kanban-swimlane-template" },
Height = "auto",
AriaLabel = "Task board"
})
<template id="kanban-swimlane-template"><span class="kanban-swimlane-avatar">${Text}</span><span class="kanban-swimlane-name">${Text}</span></template>
<style>
.kanban-swimlane-avatar { background: #ededed; border-radius: 50%; color: #424242; display: inline-block; font-size: 0; height: 30px; line-height: 30px; margin-right: 10px; overflow: hidden; text-align: center; vertical-align: middle; white-space: nowrap; width: 30px; }
.kanban-swimlane-avatar::first-letter { font-size: 12px; font-weight: 600; }
.kanban-swimlane-name { font-weight: 600; vertical-align: middle; }
</style>
<style>
.ui-kanban-card-grabber.sf-low { background: #7ed321; }
.ui-kanban-card-grabber.sf-normal { background: #f5c518; }
.ui-kanban-card-grabber.sf-critical { background: #9c27b0; }
.ui-kanban-card-grabber.sf-breaker { background: #e53935; }
</style>
@Html.UiKanban(new UiKanbanOptions
{
Id = "swimlaneTemplateBoard",
DataSource = (IEnumerable<object>)ViewData["DataSource"],
KeyField = "Status",
CardSettings = new UiKanbanCardSettings { HeaderField = "Id", ContentField = "Summary", TagsField = "Tags", GrabberField = "Cls" },
Columns = new List<UiKanbanColumn>
{
new UiKanbanColumn { KeyField = "Open", HeaderText = "To Do" },
new UiKanbanColumn { KeyField = "InProgress", HeaderText = "In Progress" },
new UiKanbanColumn { KeyField = "Testing, Validate", HeaderText = "In Review" },
new UiKanbanColumn { KeyField = "Close", HeaderText = "Done" }
},
SwimlaneSettings = new UiKanbanSwimlaneSettings { KeyField = "Assignee", Template = "#kanban-swimlane-template" },
Height = "auto",
AriaLabel = "Task board"
})
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class KanbanController : Controller
{
// The page is Views/Kanban/SwimlaneTemplate.cshtml; it draws what ViewData holds.
public ActionResult SwimlaneTemplate()
{
ViewData["DataSource"] = OverviewCards();
return View();
}
private const string Open = "Open";
private const string InProgress = "InProgress";
/// <summary>Syncfusion's Overview data: tasks by assignee, a priority (its colour), and up to two tags.</summary>
private static List<object> OverviewCards()
{
// Syncfusion's Overview data: tasks by assignee, a priority (its colour), and up to two tags.
string[][] rows =
{
new[] { "Task - 29033", "Open", "Arrange web meeting with customer to get editing requirements.", "sf-breaker", "Story", "Improvement", "Andrew Fuller" },
new[] { "Task - 29002", "InProgress", "Add responsive support to applicaton.", "sf-normal", "Story", "Kanban", "Andrew Fuller" },
new[] { "Task - 29004", "InProgress", "Fix the issues reported in the IE browser.", "sf-critical", "Bug", "Customer", "Andrew Fuller" },
new[] { "Task - 29016", "Testing", "Fix the issues reported in IE browser.", "sf-critical", "Bug", "Customer", "Andrew Fuller" },
new[] { "Task - 29018", "Close", "Arrange web meeting with customer to get login page requirement.", "sf-critical", "Feature", "", "Andrew Fuller" },
new[] { "Task - 29025", "Close", "Add input validation for editing.", "sf-breaker", "Bug", "Breaking Issue", "Andrew Fuller" },
new[] { "Task - 29003", "Open", "Show the retrived data from the server in grid control.", "sf-breaker", "Bug", "Breaking Issue", "Janet Leverling" },
new[] { "Task - 29030", "InProgress", "Test editing functionality.", "sf-normal", "Story", "", "Janet Leverling" },
new[] { "Task - 29017", "Testing", "Enhance editing functionality.", "sf-low", "Story", "Kanban", "Janet Leverling" },
new[] { "Task - 29022", "Close", "Analyze stored procedure.", "sf-breaker", "CustomSample", "", "Janet Leverling" },
new[] { "Task - 29031", "Open", "Fix the issues reported by the customer.", "sf-normal", "Bug", "Customer", "Janet Leverling" },
new[] { "Task - 29019", "Validate", "Validate the new requirements.", "sf-low", "Story", "", "Janet Leverling" }
};
return rows.Select(r => (object)new Dictionary<string, object>
{
{ "Id", r[0] }, { "Status", r[1] }, { "Summary", r[2] }, { "Cls", r[3] }, { "Tag1", r[4] }, { "Tag2", r[5] },
{ "Tags", string.Join(",", new[] { r[4], r[5] }.Where(t => t.Length > 0)) }, { "Type", r[4] }, { "Estimate", (Array.IndexOf(rows, r) % 5 + 1) * 0.5 },
{ "Assignee", r[6] }, { "Initials", string.Concat(r[6].Split(' ').Select(w => w.Substring(0, 1))) }
}).ToList();
}
}
}
@* Install once: Install-Package Lumen.UI.Mvc (or: dotnet add package Lumen.UI.Mvc) *@
@* Views/Web.config: <add namespace="Lumen.UI.Mvc" /> *@
@* Views/Shared/_Layout.cshtml *@
<head>
@Html.UiStyles()
<link rel="stylesheet" href="~/Content/site.css" />
</head>
<body>
@RenderBody()
@Html.UiScripts()
@RenderSection("scripts", required: false)
</body>
This sample demonstrates swimlane header customization in the Kanban component using the Template property of SwimlaneSettings. A custom template can be defined using the ID of an HTML element to personalize the appearance of swimlane headers.
In this sample, each swimlane header is rendered with resource-specific information, including an avatar and assignee details, providing a more intuitive and visually engaging way to identify workflow ownership.