Example of Dock in ASP.NET MVC Sidebar Control
The Sidebar dock sample demonstrates the dock functionalities of the Sidebar. Click on the hamburger menu icon to expand/collapse the sidebar with dock state.
The ASP.NET MVC DataGrid is a feature-rich component useful for displaying data in a tabular format. Its wide range of functionalities includes data binding, editing, Excel-like filtering, custom sorting, aggregating rows, selection, and support for Excel, CSV, and PDF formats. It loads millions of records in just a second.
@Html.UiToolbar(new UiToolbarOptions { Id = "dockToolbar", Items = (List<UiToolbarItem>)ViewData["DockToolItems"], OnClick = "toggleSidebar" })
<style>
.sb-toolbar .ui-toolbar { border: 1px solid var(--ui-border); border-bottom: 0; border-radius: 4px 4px 0 0; }
.sb-frame { position: relative; display: flex; height: 380px; overflow: hidden; border: 1px solid var(--ui-border); border-radius: 0 0 4px 4px; background: var(--ui-surface); }
.sb-frame.sb-alone { border-radius: 4px; }
.sb-frame > .ui-sidebar { z-index: 20; }
.sb-main { flex: 1 1 auto; min-width: 0; overflow: auto; padding: 15px; box-sizing: border-box; font-size: 14px; }
.sb-side { padding: 15px; }
.e-folder-name { font-size: 16px; font-weight: 600; padding-left: 6px; }
.e-user-name { font-size: 14px; padding-right: 6px; }
.e-user-avatar { display: inline-flex; width: 32px; height: 32px; align-items: center; justify-content: center; border-radius: 50%; background: var(--ui-accent); color: var(--ui-on-accent); font-weight: 600; }
.sb-mail, .sb-list { list-style: none; margin: 0; padding: 0; }
.sb-mail li { display: grid; grid-template-columns: 40px 1fr; column-gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--ui-border); }
.sb-mail .e-avatar { grid-row: span 3; align-self: center; width: 36px; height: 36px; border-radius: 50%; background: var(--ui-row-hover-bg); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.sb-mail .e-list-item-header { font-weight: 600; }
.sb-mail .e-list-content { color: var(--ui-text); }
.sb-mail .e-list-text { color: var(--ui-muted); font-size: 12px; }
.sb-heading { font-size: 18px; font-weight: 600; margin: 0 0 8px; }
.sb-paragraph { margin: 0 0 16px; text-align: justify; }
.sb-list li button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.sb-list li button:hover { background: var(--ui-row-hover-bg); }
.sb-list li button[aria-current="true"] { background: var(--ui-row-hover-bg); font-weight: 600; }
.sb-list .e-icons { flex: none; width: 24px; height: 24px; font-size: 20px; }
.sb-list .sb-text { white-space: nowrap; overflow: hidden; }
.ui-sidebar-dock:not(.ui-sidebar-open) .sb-text { display: none; }
</style>
@using Lumen.UI.Mvc.Demo.Controllers
<div class="control-section">
<div class="sb-toolbar">
@Html.UiToolbar(new UiToolbarOptions { Id = "dockToolbar", Items = (List<UiToolbarItem>)ViewData["DockToolItems"], OnClick = "toggleSidebar" })
</div>
<div class="sb-frame">
@using (Html.BeginUiSidebar(new UiSidebarOptions { Id = "dockSidebar", Contained = true, Type = UiSidebarType.Push, EnableDock = true, DockSize = "60px", Width = "220px", CssClass = "dockSidebar" }))
{
<ul class="sb-list e-template-list" id="dockList">
@foreach (var data in (List<NavigationDemoController.SidebarDockItem>)ViewData["ListData"])
{
<li><button type="button" data-description="@data.Description" title="@data.Text"><span class="@data.IconCss" aria-hidden="true"></span><span class="sb-text">@data.Text</span></button></li>
}
</ul>
}
<div class="sb-main dockmaincontent">
<div id="dockContent" class="dockcontent">
The ASP.NET MVC DataGrid is a feature-rich component useful for displaying data in a tabular format. Its wide range of functionalities includes data binding, editing, Excel-like filtering, custom sorting, aggregating rows, selection, and support for Excel, CSV, and PDF formats. It loads millions of records in just a second.
</div>
</div>
</div>
</div>
<script>
// Syncfusion: the Menu button of the Toolbar toggles the Sidebar
function toggleSidebar(item) {
if (item.id === 'menu') { window.Lumen.get('dockSidebar').toggle(); }
}
</script>
<script>
// Syncfusion: selecting an item of the ListView shows its description
document.getElementById('dockList').addEventListener('click', function (e) {
var button = e.target.closest('button');
if (!button) { return; }
document.getElementById('dockContent').textContent = button.getAttribute('data-description');
this.querySelectorAll('button').forEach(function (b) { b.removeAttribute('aria-current'); });
button.setAttribute('aria-current', 'true');
});
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class SidebarController : Controller
{
// The page is Views/Sidebar/Dock.cshtml; it draws what ViewData holds.
public ActionResult Dock()
{
ViewData["DockToolItems"] = new List<UiToolbarItem>
{
new UiToolbarItem { Id = "menu", IconCss = "e-icons e-menu", TooltipText = "Menu" },
new UiToolbarItem { Type = UiToolbarItemType.Input, HtmlContent = new HtmlString("<div class='e-folder'><div class='e-folder-name'>ASP.NET MVC Documentation</div></div>") }
};
ViewData["ListData"] = new List<SidebarDockItem>
{
new SidebarDockItem { Text = "Grid", IconCss = "e-icons e-menu", Description = "The ASP.NET MVC DataGrid is a feature-rich component useful for displaying data in a tabular format. Its wide range of functionalities includes data binding, editing, Excel-like filtering, custom sorting, aggregating rows, selection, and support for Excel, CSV, and PDF formats. It loads millions of records in just a second. It has flexible editing and intuitive record selection modes. Also, it has seamless data exporting options like PDF, CSV, and Excel." },
new SidebarDockItem { Text = "Chart", IconCss = "e-icons e-zoom-in", Description = "The ASP.NET MVC Charts is a well-crafted charting component to visualize data. It contains a rich UI gallery of 30+ charts and graphs, ranging from line to financial that cater to all charting scenarios. Its high performance helps to render large amounts of data quickly. It also comes with features such as zooming, panning, tooltip, crosshair, trackball, highlight, and selection." },
new SidebarDockItem { Text = "Datepicker", IconCss = "e-icons e-folder", Description = "The ASP.NET MVC DatePicker is a lightweight and mobile-friendly component that allows end-users to enter or select a date value. It has month, year, and decade view options to quickly navigate to the desired date. It supports minimum dates, maximum dates, and disabled dates to restrict the date selection. It has built-in features such as validation, custom date formats, range restriction, and disable dates to enhance the progressive usage." },
new SidebarDockItem { Text = "Dialog", IconCss = "e-icons e-comment", Description = "The ASP.NET MVC Dialog is a useful user interface (UI) component for informing users about critical information, errors, warnings, and questions, as well as confirming decisions and collecting input from users. The component has a rich set of built-in features such as action buttons, positioning, animations, dragging, resizing, templating, and more with mobile dialog support. The ASP.NET MVC dialog provides two different types: modal dialogs and non-modal dialogs (modeless) based on interactions." },
new SidebarDockItem { Text = "Dropdown List", IconCss = "e-icons e-list-unordered", Description = "The ASP.NET MVC Dropdown List is a quick replacement of the HTML select tags. It has a rich appearance and allows users to select a single value that is non-editable from a list of predefined values. It has several out-of-the-box features, such as data binding, filtering, grouping, UI customization, accessibility, and preselected values." }
};
return View();
}
/// <summary>An item of the Dock sample's list.</summary>
public class SidebarDockItem
{
public string Text { get; set; }
public string IconCss { get; set; }
public string Description { get; set; }
}
}
}
@* 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>
Dock state of the Sidebar reserves some space on the page that always remains in a visible state when the Sidebar is collapsed. It is used to show the short term of a content like icons alone instead of lengthy text.
In this demo, the list item has an icon with text representation. On dock state, only the icon listed out to interact. It can be achieved by using the EnableDock property.