KanbanBoard
Wisej.NET 4.2.0+
The KanbanBoard shows the records of a data source as cards in columns, one column per status. Users drag a card to another column to change its status, or within a column to change its order, and the board writes the new values back to the record — after your code has had the chance to cancel the move.
Use it for anything that moves through stages: support tickets, sales opportunities, orders being picked and shipped, job applications. It works from the same lists, DataTables and BindingSources you would give a DataGridView, so the same records can be shown as a board on one screen and as a grid on another. For work laid out along dates rather than stages, use a GanttView.
For a complete list of properties, methods, and events, see the API documentation.
Features
Columns
Columns holds the KanbanColumn lanes, in order. A column has a Text for its heading and a Value, which is matched against the record's status. Tone, a MeterTone, colours the dot in the heading. WipLimit caps the number of cards the column accepts (zero, the default, means no limit), and AllowDrop = false closes it to moves altogether — for an "Archived" lane, say.
The heading shows the number of cards, and with a limit set, the number against the limit; it turns to the warning colour once the limit is reached. A move into a full column is rejected and raises WipLimitExceeded. Cards already over the limit when you set it stay where they are.
Data Source and Card Fields
DataSource takes an IList, an IListSource such as a DataTable, or a BindingSource. Every record whose status matches a column Value becomes a card; records that match no column stay in the source and are not shown.
The built-in card is filled from the members you name:
| Property | Default | Shown as |
|---|---|---|
StatusMember | Status | The column the card is in. Must be writable for moves. |
TitleMember | Title | The card title. |
MetaMember | — | A line of secondary text. |
TagMember, TagToneMember | — | A coloured tag, and its MeterTone as a name or a value. |
AvatarMember | — | A person's name, shown as initials. |
ProgressMember | — | A thin progress bar, 0 to 100. |
OrderMember | — | A writable number for the card's position in its column. |
With OrderMember set, a move rewrites the order of the affected columns as consecutive positions starting at zero, so the order survives a reload. Without it, the order is kept for the session only.
A BindingList<T>, a DataTable or records that raise change notifications refresh the board on their own. After changing a plain list, call RefreshData(), or RefreshCard(item) for a single record.
Moving Cards
AllowDrag enables moving cards between columns, and AllowReorder moving them within one; both are on by default. Cards can be moved from the keyboard too: Alt with Left or Right changes column, Alt with Up or Down changes position.
From code, MoveCard(item, column, index) makes the same move, with the same validation and events; it returns false when the move is cancelled or rejected. An index of -1, the default, appends the card.
Events
| Event | Raised when | Event data |
|---|---|---|
CardMoving | Before a move is committed. Set Cancel to reject it. | KanbanCardMoveEventArgs: Item, OldColumn, Column, Index |
CardMoved | After the status and order have been written. | KanbanCardMoveEventArgs |
WipLimitExceeded | A move was rejected because the destination column is full. | KanbanCardMoveEventArgs |
CardClick, CardDoubleClick | A card is clicked (or activated with Enter or Space), or double-clicked. | KanbanCardEventArgs: Item, Column |
Item is always your original record.
Layout
ColumnWidth is the width of a lane in pixels, 260 by default. With AutoSizeColumns on, the default, lanes share the available width and ColumnWidth is their minimum; the board scrolls sideways when they do not fit. MaxVisibleCards limits how many cards a column shows at first (20 by default), with a "more" button to show the rest.
Custom Cards
When the built-in card is not enough, set CardTemplate to the type of a UserControl of your own with a public parameterless constructor. The board creates one for each visible card, sets its Tag to the record and, if the control implements IKanbanCardTemplate, assigns the record to its DataItem property, which is where you fill in the controls. The board owns these instances and disposes them, so keep any state in the record rather than in the control.
How To
Show Tickets as a Board
this.kanbanBoard1.Columns.Add(new KanbanColumn { Text = "New", Value = "new", Tone = MeterTone.Neutral });
this.kanbanBoard1.Columns.Add(new KanbanColumn { Text = "In progress", Value = "open", Tone = MeterTone.Primary, WipLimit = 3 });
this.kanbanBoard1.Columns.Add(new KanbanColumn { Text = "Waiting", Value = "waiting", Tone = MeterTone.Warning });
this.kanbanBoard1.Columns.Add(new KanbanColumn { Text = "Resolved", Value = "resolved", Tone = MeterTone.Success });
this.kanbanBoard1.StatusMember = "Status";
this.kanbanBoard1.TitleMember = "Subject";
this.kanbanBoard1.MetaMember = "Customer";
this.kanbanBoard1.TagMember = "Priority";
this.kanbanBoard1.TagToneMember = "PriorityTone";
this.kanbanBoard1.AvatarMember = "AssignedTo";
this.kanbanBoard1.OrderMember = "Rank";
this.kanbanBoard1.DataSource = new BindingList<Ticket>(db.Tickets.ToList());
Enforce a Workflow
Cancel moves your process does not allow, and tell the user why a full column turned a card away.
private void kanbanBoard1_CardMoving(object sender, KanbanCardMoveEventArgs e)
{
var ticket = (Ticket)e.Item;
// A ticket can only be resolved once someone has picked it up.
if (e.Column.Value == "resolved" && string.IsNullOrEmpty(ticket.AssignedTo))
e.Cancel = true;
}
private void kanbanBoard1_WipLimitExceeded(object sender, KanbanCardMoveEventArgs e)
{
AlertBox.Show($"\"{e.Column.Text}\" already holds {e.Column.WipLimit} tickets.", MessageBoxIcon.Warning);
}
Save a Move and Open a Card
private void kanbanBoard1_CardMoved(object sender, KanbanCardMoveEventArgs e)
{
// Status and Rank have already been written to the record.
db.SaveChanges();
}
private void kanbanBoard1_CardDoubleClick(object sender, KanbanCardEventArgs e)
{
new TicketForm((Ticket)e.Item).ShowDialog();
}
Design Your Own Card
public partial class TicketCard : UserControl, IKanbanCardTemplate
{
private Ticket ticket;
public object DataItem
{
get => this.ticket;
set
{
this.ticket = (Ticket)value;
this.labelSubject.Text = this.ticket.Subject;
this.labelDue.Text = $"Due {this.ticket.DueDate:d}";
}
}
}
// In the form:
this.kanbanBoard1.CardTemplate = typeof(TicketCard);
Advanced
JavaScript Widget
| Item | Description |
|---|---|
| Class name | "wisej.web.KanbanBoard" |
| Theme appearance | "kanbanboard", see Themes. Its parts have appearances of their own: "kanbanboard-column", "kanbanboard-heading" (with "-dot", "-title" and "-count"), "kanbanboard-cards", "kanbanboard-card", "kanbanboard-title", "kanbanboard-meta", "kanbanboard-tag", "kanbanboard-avatar", "kanbanboard-progress", "kanbanboard-more", "kanbanboard-placeholder" and "kanbanboard-drag-preview". |