Example of Search and Filter Cards in ASP.NET MVC Kanban Control
This sample demonstrates the filtering and searching capabilities of the Kanban component, enabling users to quickly locate and organize cards based on specific criteria.
To Do
In Progress
Done
Filtering
Searching
<template id="kanban-col-todo"><span class="ui-kanban-col-icon ui-kanban-col-todo"></span>To Do</template>
<template id="kanban-col-progress"><span class="ui-kanban-col-icon ui-kanban-col-progress"></span>In Progress</template>
<template id="kanban-col-done"><span class="ui-kanban-col-icon ui-kanban-col-done"></span>Done</template>
@Html.UiKanban(new UiKanbanOptions
{
Id = "searchBoard",
DataSource = (IEnumerable<object>)ViewData["DataSource"],
CardSettings = new UiKanbanCardSettings { TagsField = "Tags", GrabberField = "Priority" },
Columns = new List<UiKanbanColumn>
{
new UiKanbanColumn { Key = "Open", Text = "To Do", Template = "#kanban-col-todo" },
new UiKanbanColumn { Key = "InProgress", Text = "In Progress", Template = "#kanban-col-progress" },
new UiKanbanColumn { Key = "Done", Text = "Done", Template = "#kanban-col-done" }
},
Height = "460px",
AriaLabel = "Release workflow board"
})
<div class="demo-property-panel">
<h3>Filtering</h3>
<div class="demo-property-row"><label for="priorityFilter">Priority</label><select id="priorityFilter"><option value="None">None</option><option value="sf-low">Low</option><option value="sf-normal">Normal</option><option value="sf-critical">Critical</option><option value="sf-breaker">Release Breaker</option></select></div>
<div class="demo-property-row"><label for="statusFilter">Status</label><select id="statusFilter"><option value="None">None</option><option value="Open">To Do</option><option value="InProgress">In Progress</option><option value="Done">Done</option></select></div>
<h3>Searching</h3>
<div class="demo-property-row"><input id="searchText" type="search" placeholder="Enter search text" aria-label="Search text" /><button type="button" id="resetFilter">Reset</button></div>
</div>
<script>
(function () {
var board = function () { return window.Lumen.get('searchBoard'); };
var priority = document.getElementById('priorityFilter'), status = document.getElementById('statusFilter'), text = document.getElementById('searchText');
// A filter and the search clear each other, as Syncfusion's panel does when it sets the board's query.
priority.addEventListener('change', function () {
status.value = 'None';
board().setQuery(priority.value === 'None' ? null : { filter: { field: 'Priority', value: priority.value } });
});
status.addEventListener('change', function () {
priority.value = 'None';
board().setQuery(status.value === 'None' ? null : { filter: { field: 'Status', value: status.value } });
});
text.addEventListener('input', function () {
board().setQuery(text.value ? { search: { text: text.value, fields: ['Id', 'Header', 'Content'] } } : null);
});
document.getElementById('resetFilter').addEventListener('click', function () {
priority.value = 'None';
status.value = 'None';
text.value = '';
board().setQuery(null);
});
}());
</script>
<template id="kanban-col-todo"><span class="ui-kanban-col-icon ui-kanban-col-todo"></span>To Do</template>
<template id="kanban-col-progress"><span class="ui-kanban-col-icon ui-kanban-col-progress"></span>In Progress</template>
<template id="kanban-col-done"><span class="ui-kanban-col-icon ui-kanban-col-done"></span>Done</template>
<style>
.ui-kanban-col-icon { align-items: center; border-radius: 3px; color: #fff; display: inline-flex; font-size: 11px; height: 16px; justify-content: center; margin-right: 8px; width: 16px; }
.ui-kanban-col-todo { background: #2563eb; }
.ui-kanban-col-progress { background: #f59e0b; }
.ui-kanban-col-review { background: #9c27b0; }
.ui-kanban-col-done { background: #43a047; }
.ui-kanban-col-todo::before { content: "\2630"; }
.ui-kanban-col-progress::before { content: "\2731"; }
.ui-kanban-col-review::before { content: "\25C9"; }
.ui-kanban-col-done::before { content: "\2714"; }
</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 = "searchBoard",
DataSource = (IEnumerable<object>)ViewData["DataSource"],
CardSettings = new UiKanbanCardSettings { TagsField = "Tags", GrabberField = "Priority" },
Columns = new List<UiKanbanColumn>
{
new UiKanbanColumn { Key = "Open", Text = "To Do", Template = "#kanban-col-todo" },
new UiKanbanColumn { Key = "InProgress", Text = "In Progress", Template = "#kanban-col-progress" },
new UiKanbanColumn { Key = "Done", Text = "Done", Template = "#kanban-col-done" }
},
Height = "460px",
AriaLabel = "Release workflow board"
})
<div class="demo-property-panel">
<h3>Filtering</h3>
<div class="demo-property-row"><label for="priorityFilter">Priority</label><select id="priorityFilter"><option value="None">None</option><option value="sf-low">Low</option><option value="sf-normal">Normal</option><option value="sf-critical">Critical</option><option value="sf-breaker">Release Breaker</option></select></div>
<div class="demo-property-row"><label for="statusFilter">Status</label><select id="statusFilter"><option value="None">None</option><option value="Open">To Do</option><option value="InProgress">In Progress</option><option value="Done">Done</option></select></div>
<h3>Searching</h3>
<div class="demo-property-row"><input id="searchText" type="search" placeholder="Enter search text" aria-label="Search text" /><button type="button" id="resetFilter">Reset</button></div>
</div>
<script>
(function () {
var board = function () { return window.Lumen.get('searchBoard'); };
var priority = document.getElementById('priorityFilter'), status = document.getElementById('statusFilter'), text = document.getElementById('searchText');
// A filter and the search clear each other, as Syncfusion's panel does when it sets the board's query.
priority.addEventListener('change', function () {
status.value = 'None';
board().setQuery(priority.value === 'None' ? null : { filter: { field: 'Priority', value: priority.value } });
});
status.addEventListener('change', function () {
priority.value = 'None';
board().setQuery(status.value === 'None' ? null : { filter: { field: 'Status', value: status.value } });
});
text.addEventListener('input', function () {
board().setQuery(text.value ? { search: { text: text.value, fields: ['Id', 'Header', 'Content'] } } : null);
});
document.getElementById('resetFilter').addEventListener('click', function () {
priority.value = 'None';
status.value = 'None';
text.value = '';
board().setQuery(null);
});
}());
</script>
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/SearchAndFilterCards.cshtml; it draws what ViewData holds.
public ActionResult SearchAndFilterCards()
{
ViewData["DataSource"] = Cards();
return View();
}
private const string Open = "Open";
private const string InProgress = "InProgress";
private const string Done = "Done";
/// <summary>The release-board cards most samples share.</summary>
private static List<UiKanbanCard> Cards()
{
return new List<UiKanbanCard>
{
new UiKanbanCard { Id = "1", Header = "Prepare release pipeline", Content = "Plan the next release and verify its build steps.", Status = Open, Swimlane = "High", Order = 3, Tags = "Story,Kanban", Priority = "sf-breaker" },
new UiKanbanCard { Id = "2", Header = "Review pull request", Content = "Check changes before the release candidate.", Status = Open, Swimlane = "Normal", Order = 2, Tags = "Bug,Customer", Priority = "sf-normal" },
new UiKanbanCard { Id = "3", Header = "Review change set", Content = "Resolve comments from the implementation review.", Status = InProgress, Swimlane = "High", Order = 1, Tags = "Story", Priority = "sf-critical" },
new UiKanbanCard { Id = "4", Header = "Publish package", Content = "Publish the approved build to the package feed.", Status = Done, Swimlane = "Normal", Order = 4, Tags = "Feature", Priority = "sf-low" },
new UiKanbanCard { Id = "5", Header = "Release planning", Content = "Planning notes for the next scheduled release.", Status = Open, Swimlane = "High", Order = 5, Tags = "Improvement", Priority = "sf-low" }
};
}
}
}
@* 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 the cards of the board are searched and filtered. The search box shows only the cards whose text matches what is typed, and the filter shows only the cards that match the field it is given; clearing them brings all the cards back.
EnableSearch- Shows the search box above the board.EnableFilter- Shows the filter above the board.