Example of Dialog Editing in ASP.NET MVC Kanban Control
This sample demonstrates dialog editing capabilities in the Kanban component, enabling users to efficiently manage cards through a customizable dialog interface and perform common data management operations within the board.
Edit Card Details
Properties
<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 = "editBoard",
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" }
},
EnableEditing = true,
EditDialogId = "editDialog",
Height = "460px",
AriaLabel = "Release workflow board"
})
@using (Html.BeginUiDialog(new UiDialogOptions
{
Id = "editDialog",
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>
}
<div class="demo-property-panel">
<h3>Properties</h3>
<div class="demo-property-row"><button type="button" id="addNew">Add New Card</button></div>
</div>
<script>
document.getElementById('addNew').addEventListener('click', function () {
window.Lumen.get('editBoard').openDialog('Add');
});
</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 = "editBoard",
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" }
},
EnableEditing = true,
EditDialogId = "editDialog",
Height = "460px",
AriaLabel = "Release workflow board"
})
@using (Html.BeginUiDialog(new UiDialogOptions
{
Id = "editDialog",
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>
}
<div class="demo-property-panel">
<h3>Properties</h3>
<div class="demo-property-row"><button type="button" id="addNew">Add New Card</button></div>
</div>
<script>
document.getElementById('addNew').addEventListener('click', function () {
window.Lumen.get('editBoard').openDialog('Add');
});
</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/DialogEditing.cshtml; it draws what ViewData holds.
public ActionResult DialogEditing()
{
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 dialog-based CRUD operations in the Kanban component. The board is populated using the DataSource collection, where tasks are organized into Columns based on their Status field.
New cards can be created using the openDialog method. Existing cards can be viewed, edited, or deleted through a customized dialog interface. The dialog is rendered using the DialogSettings property, while the OnDialogOpen event is used to initialize and configure the dialog input controls.