Example of Responsive Panel in ASP.NET MVC Sidebar Control
The Sidebar sample demonstrates how the Sidebar will act in responsive case. Click on the hamburger menu icon to expand/collapse the sidebar.
Navigation Pane
Responsive Sidebar with Treeview
This is a graphical aid for visualising and categorising the site, in the style of an expandable and collapsable treeview component. It auto-expands to display the node(s), if any, corresponding to the currently viewed title, highlighting that node(s) and its ancestors. Load-on-demand when expanding nodes is available where supported (most graphical browsers), falling back to a full-page reload. MediaWiki-supported caching, aside from squid, has been considered so that unnecessary re-downloads of content are avoided where possible. The complete expanded/collapsed state of the treeview persists across page views in most situations.
<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; }
.main-menu-header { margin: 14px 0 6px; font-size: 12px; font-weight: 600; color: var(--ui-muted); }
</style>
<div class="control-section">
<div class="sb-toolbar">
@Html.UiToolbar(new UiToolbarOptions { Id = "resToolbar", Items = (List<UiToolbarItem>)ViewData["ResToolItems"], OnClick = "toggleSidebar" })
</div>
<div class="sb-frame">
@using (Html.BeginUiSidebar(new UiSidebarOptions { Id = "sideTree", Contained = true, Type = UiSidebarType.Push, Width = "290px", MediaQuery = "(min-width: 600px)", IsOpen = true, CssClass = "sidebar-treeview" }))
{
<div class="main-menu sb-side">
<div class="table-content">
@Html.UiTextBox("resSearch", null, new UiTextBoxOptions { Placeholder = "Search..." })
<p class="main-menu-header">TABLE OF CONTENTS</p>
</div>
@Html.UiTreeView(new UiTreeViewOptions { Id = "mainTree", CssClass = "main-treeview", ExpandOn = UiTreeExpandOn.Click, Nodes = (List<UiTreeNode>)ViewData["TreeData"] })
</div>
}
<div class="sb-main main-content" id="main-text">
<div class="sidebar-content">
<div class="sb-heading"> Responsive Sidebar with Treeview</div>
<p class="sb-paragraph">This is a graphical aid for visualising and categorising the site, in the style of an expandable and collapsable treeview component. It auto-expands to display the node(s), if any, corresponding to the currently viewed title, highlighting that node(s) and its ancestors. Load-on-demand when expanding nodes is available where supported (most graphical browsers), falling back to a full-page reload. MediaWiki-supported caching, aside from squid, has been considered so that unnecessary re-downloads of content are avoided where possible. The complete expanded/collapsed state of the treeview persists across page views in most situations.</p>
</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('sideTree').toggle(); }
}
</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/PanelWithResponsive.cshtml; it draws what ViewData holds.
public ActionResult PanelWithResponsive()
{
ViewData["ResToolItems"] = 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'>Navigation Pane</div></div>") }
};
ViewData["TreeData"] = new List<UiTreeNode>
{
new UiTreeNode { Id = "01", Text = "Installation" },
new UiTreeNode { Id = "02", Text = "Deployment" },
new UiTreeNode { Id = "03", Text = "Quick Start" },
new UiTreeNode { Id = "04", Text = "Components", Children = { new UiTreeNode { Id = "04-01", Text = "Calendar" }, new UiTreeNode { Id = "04-02", Text = "DatePicker" }, new UiTreeNode { Id = "04-03", Text = "DateTimePicker" }, new UiTreeNode { Id = "04-04", Text = "DateRangePicker" }, new UiTreeNode { Id = "04-05", Text = "TimePicker" }, new UiTreeNode { Id = "04-06", Text = "SideBar" } } },
new UiTreeNode { Id = "05", Text = "API Reference", Children = { new UiTreeNode { Id = "05-01", Text = "Calendar" }, new UiTreeNode { Id = "05-02", Text = "DatePicker" }, new UiTreeNode { Id = "05-03", Text = "DateTimePicker" }, new UiTreeNode { Id = "05-04", Text = "DateRangePicker" }, new UiTreeNode { Id = "05-05", Text = "TimePicker" }, new UiTreeNode { Id = "05-06", Text = "SideBar" } } },
new UiTreeNode { Id = "06", Text = "Browser Compatibility" },
new UiTreeNode { Id = "07", Text = "Upgrade Packages" },
new UiTreeNode { Id = "08", Text = "Release Notes" },
new UiTreeNode { Id = "09", Text = "FAQ" },
new UiTreeNode { Id = "10", Text = "License" }
};
return View();
}
}
}
The Sidebar will be shown or hidden based on the resolutions of the screen. It will be shown on larger resolution screens and hidden automatically in lower resolution screens.
In this sample, the TreeView component is placed inside the Sidebar.