Example of Card Template in ASP.NET MVC Kanban Control
This sample demonstrates how to customize the appearance and editing experience of Kanban cards using card and dialog templates.
${Icon}
${Name}
${Description}
<template id="kanban-card-template"><div class="kanban-pizza"><div class="kanban-pizza-picture">${Icon}</div><div class="kanban-pizza-body"><div class="kanban-pizza-title">${Name}</div><div class="kanban-pizza-description">${Description}</div><div class="kanban-pizza-footer"><span class="kanban-template-status">${Status}</span><span class="kanban-pizza-tag">${Tag1}</span><span class="kanban-pizza-tag">${Tag2}</span></div></div></div></template>
@Html.UiKanban(new UiKanbanOptions
{
Id = "cardTemplateBoard",
DataSource = (IEnumerable<object>)ViewData["DataSource"],
KeyField = "Status",
CardSettings = new UiKanbanCardSettings { HeaderField = "Id", ContentField = "Description", Template = "#kanban-card-template" },
Columns = new List<UiKanbanColumn>
{
new UiKanbanColumn { Key = "Open", Text = "Ordered" },
new UiKanbanColumn { Key = "InProgress", Text = "Preparing" },
new UiKanbanColumn { Key = "Done", Text = "Delivered" }
},
Height = "auto",
AriaLabel = "Pizza orders board"
})
<template id="kanban-card-template"><div class="kanban-pizza"><div class="kanban-pizza-picture">${Icon}</div><div class="kanban-pizza-body"><div class="kanban-pizza-title">${Name}</div><div class="kanban-pizza-description">${Description}</div><div class="kanban-pizza-footer"><span class="kanban-template-status">${Status}</span><span class="kanban-pizza-tag">${Tag1}</span><span class="kanban-pizza-tag">${Tag2}</span></div></div></div></template>
<style>
.kanban-pizza { align-items: flex-start; display: flex; gap: 12px; padding: 12px 14px; }
.kanban-pizza-picture { align-items: center; background: #fff3e0; border-radius: 8px; display: flex; flex: 0 0 56px; font-size: 30px; height: 56px; justify-content: center; }
.kanban-pizza-body { min-width: 0; }
.kanban-pizza-title { font-size: 14px; font-weight: 600; }
.kanban-pizza-description { font-size: 13px; line-height: 1.5; margin: 4px 0 8px; }
.kanban-pizza-footer { align-items: center; display: flex; flex-wrap: wrap; gap: 4px; }
.kanban-template-status { background: #e3f2fd; border-radius: 10px; color: #0f6cbd; font-size: 11px; font-weight: 600; padding: 1px 8px; }
.kanban-pizza-tag { background: #ededed; border-radius: 2px; font-size: 12px; padding: 1px 6px; }
.kanban-pizza-tag:empty { display: none; }
</style>
@Html.UiKanban(new UiKanbanOptions
{
Id = "cardTemplateBoard",
DataSource = (IEnumerable<object>)ViewData["DataSource"],
KeyField = "Status",
CardSettings = new UiKanbanCardSettings { HeaderField = "Id", ContentField = "Description", Template = "#kanban-card-template" },
Columns = new List<UiKanbanColumn>
{
new UiKanbanColumn { Key = "Open", Text = "Ordered" },
new UiKanbanColumn { Key = "InProgress", Text = "Preparing" },
new UiKanbanColumn { Key = "Done", Text = "Delivered" }
},
Height = "auto",
AriaLabel = "Pizza orders 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/CardTemplate.cshtml; it draws what ViewData holds.
public ActionResult CardTemplate()
{
ViewData["DataSource"] = PizzaOrders();
return View();
}
private const string Open = "Open";
private const string InProgress = "InProgress";
private const string Done = "Done";
/// <summary>Syncfusion's Card Template data: pizza orders with a picture, a title, a description, a status and tags.</summary>
private static List<object> PizzaOrders()
{
string[][] rows =
{
new[] { "Margherita", "Tomato, mozzarella and fresh basil on a thin crust.", "Open", "\U0001F355", "Vegetarian", "Classic" },
new[] { "Pepperoni", "Spicy pepperoni with extra mozzarella.", "Open", "\U0001F336", "Spicy", "Bestseller" },
new[] { "Hawaiian", "Ham and pineapple with a sweet tomato base.", "InProgress", "\U0001F34D", "Sweet", "" },
new[] { "Four Cheese", "Mozzarella, gorgonzola, parmesan and fontina.", "InProgress", "\U0001F9C0", "Vegetarian", "Rich" },
new[] { "Garden Veggie", "Peppers, olives, mushrooms and onion.", "Done", "\U0001F96C", "Vegan", "Light" }
};
return rows.Select((r, i) => (object)new Dictionary<string, object>
{
{ "Id", "Order " + (1001 + i) }, { "Name", r[0] }, { "Description", r[1] }, { "Status", r[2] }, { "Icon", r[3] }, { "Tag1", r[4] }, { "Tag2", r[5] }
}).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 how to customize the appearance of Kanban cards using a template. The Template property of CardSettings allows you to define a custom card layout using the ID of an HTML element. In this sample, the card template displays order details such as the pizza picture, title, description, status indicators, and tags.