Example of API in ASP.NET MVC Kanban Control
This sample demonstrates how to add and remove columns of the Kanban component at run time using its public methods.
To Do
In Progress
Done
Add Column
Delete Column
Kanban card
Edit Card Details
<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 = "apiBoard",
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" }
},
CssClass = "kanban-sf-api",
EnableEditing = true,
EditDialogId = "apiEditDialog",
Height = "auto",
AriaLabel = "Release workflow board"
})
<div class="demo-property-panel">
<h3>Add Column</h3>
<div class="demo-property-row"><label for="kanbanAddIndex">Index</label><input id="kanbanAddIndex" type="number" min="0" value="1" /><button type="button" id="kanbanAddColumn">Add</button></div>
<h3>Delete Column</h3>
<div class="demo-property-row"><label for="kanbanDeleteIndex">Index</label><input id="kanbanDeleteIndex" type="number" min="0" value="0" /><button type="button" id="kanbanDeleteColumn">Delete</button></div>
</div>
<script>
// Syncfusion's API sample: addColumn(column, index) and deleteColumn(index) from the panel.
(function () {
var added = 0;
function board() { return window.Lumen.get('apiBoard'); }
function index(id) { var value = parseInt(document.getElementById(id).value, 10); return isNaN(value) ? 0 : value; }
document.getElementById('kanbanAddColumn').addEventListener('click', function () {
added++;
board().addColumn({ keyField: 'Review' + added, headerText: 'Review ' + added, showItemCount: true }, index('kanbanAddIndex'));
});
document.getElementById('kanbanDeleteColumn').addEventListener('click', function () {
board().deleteColumn(index('kanbanDeleteIndex'));
});
}());
</script>
@using (Html.BeginUiDialog(new UiDialogOptions
{
Id = "apiEditDialog",
Header = "Kanban card",
Width = "460px",
ShowCloseIcon = true,
IsModal = true
}))
{
<div class="ui-kanban-dialog">
<h3 data-kanban-dialog-title>Edit Card Details</h3>
<label>
Title
<input type="text" data-kanban-field="header" autocomplete="off" />
</label>
<label>
Description
<textarea data-kanban-field="content"></textarea>
</label>
<label>
Status
<select data-kanban-field="status">
<option value="Open">To Do</option>
<option value="InProgress">In Progress</option>
<option value="Done">Done</option>
</select>
</label>
<div class="ui-kanban-dialog-actions">
<button type="button" data-kanban-action="save" class="ui-kanban-btn-primary">Save</button>
<button type="button" data-kanban-action="cancel">Cancel</button>
<button type="button" data-kanban-action="delete">Delete</button>
</div>
</div>
}
<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 = "apiBoard",
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" }
},
CssClass = "kanban-sf-api",
EnableEditing = true,
EditDialogId = "apiEditDialog",
Height = "auto",
AriaLabel = "Release workflow board"
})
<div class="demo-property-panel">
<h3>Add Column</h3>
<div class="demo-property-row"><label for="kanbanAddIndex">Index</label><input id="kanbanAddIndex" type="number" min="0" value="1" /><button type="button" id="kanbanAddColumn">Add</button></div>
<h3>Delete Column</h3>
<div class="demo-property-row"><label for="kanbanDeleteIndex">Index</label><input id="kanbanDeleteIndex" type="number" min="0" value="0" /><button type="button" id="kanbanDeleteColumn">Delete</button></div>
</div>
<script>
// Syncfusion's API sample: addColumn(column, index) and deleteColumn(index) from the panel.
(function () {
var added = 0;
function board() { return window.Lumen.get('apiBoard'); }
function index(id) { var value = parseInt(document.getElementById(id).value, 10); return isNaN(value) ? 0 : value; }
document.getElementById('kanbanAddColumn').addEventListener('click', function () {
added++;
board().addColumn({ keyField: 'Review' + added, headerText: 'Review ' + added, showItemCount: true }, index('kanbanAddIndex'));
});
document.getElementById('kanbanDeleteColumn').addEventListener('click', function () {
board().deleteColumn(index('kanbanDeleteIndex'));
});
}());
</script>
@using (Html.BeginUiDialog(new UiDialogOptions
{
Id = "apiEditDialog",
Header = "Kanban card",
Width = "460px",
ShowCloseIcon = true,
IsModal = true
}))
{
<div class="ui-kanban-dialog">
<h3 data-kanban-dialog-title>Edit Card Details</h3>
<label>
Title
<input type="text" data-kanban-field="header" autocomplete="off" />
</label>
<label>
Description
<textarea data-kanban-field="content"></textarea>
</label>
<label>
Status
<select data-kanban-field="status">
<option value="Open">To Do</option>
<option value="InProgress">In Progress</option>
<option value="Done">Done</option>
</select>
</label>
<div class="ui-kanban-dialog-actions">
<button type="button" data-kanban-action="save" class="ui-kanban-btn-primary">Save</button>
<button type="button" data-kanban-action="cancel">Cancel</button>
<button type="button" data-kanban-action="delete">Delete</button>
</div>
</div>
}
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/Api.cshtml; it draws what ViewData holds.
public ActionResult Api()
{
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 to dynamically add and remove columns in the Kanban component using the available public methods.
addColumn: Adds a new column to the Kanban board at the specified position. In this sample, the column is configured using theKeyField,HeaderTextandShowItemCountproperties.deleteColumn: Removes an existing column from the Kanban board based on the specified column index.