Example of template in ASP.NET MVC MultiColumnComboBox Control
This sample demonstrates the template functionalities of the MultiColumn ComboBox.
Photo
Employee info
Date of joining
Country

${Name}
${Designation}
${DateofJoining}
${Country}
@Html.UiMultiColumnComboBox("template", new UiMultiColumnComboBoxOptions
{
Placeholder = "e.g. Andrew Fuller",
CssClass = "multicolumn-customize",
Fields = new UiDropDownFields { Text = "Name", Value = "Eimg" },
Columns = new List<UiDropDownColumn>
{
new UiDropDownColumn { Field = "Eimg", Header = "Photos", HeaderTemplate = "#hdrPhoto", Width = 90, Template = "#colPhoto" },
new UiDropDownColumn { Field = "Name", Header = "Employee Name", HeaderTemplate = "#hdrName", Width = 160, Template = "#colName" },
new UiDropDownColumn { Field = "DateofJoining", Header = "Date Of Joining", HeaderTemplate = "#hdrDate", Width = 165, Template = "#colDate" },
new UiDropDownColumn { Field = "Country", Header = "Country", HeaderTemplate = "#hdrCountry", Width = 100, Template = "#colCountry" }
},
DataSource = Model.Employees,
PopupHeight = "210px",
PopupWidth = "540px"
})
<style>
.control-section .control-wrapper { margin: 0 auto; width: 300px; padding-top: 30px; }
.control-section .control-wrapper label { display: block; margin-bottom: 6px; font-weight: 600; }
.empImage { width: 36px; height: 36px; border-radius: 50%; }
.ename { font-weight: 600; }
.job { font-size: 12px; opacity: .7; }
</style>
@using Lumen.UI.Mvc.Demo.Controllers
@model DropdownsDemoController.EmployeeViewModel
<template id="hdrPhoto"><div class="header"><span>Photo</span></div></template>
<template id="hdrName"><div class="header"><span>Employee info</span></div></template>
<template id="hdrDate"><div class="header"><span>Date of joining</span></div></template>
<template id="hdrCountry"><div class="header"><span>Country</span></div></template>
<template id="colPhoto"><div><img class="empImage" src="@Url.Content("~/Content/dropdownlist/images/Employees/")${Eimg}.png" alt="employee"/></div></template>
<template id="colName"><div class="ename"> ${Name} </div><div class="job"> ${Designation} </div></template>
<template id="colDate"><div class="dateOfJoining"> ${DateofJoining} </div></template>
<template id="colCountry"><div class="country"> ${Country} </div></template>
<div class="control-section">
<div class="control-wrapper template-multicolumn">
<label>Select an employee</label>
@Html.UiMultiColumnComboBox("template", new UiMultiColumnComboBoxOptions
{
Placeholder = "e.g. Andrew Fuller",
CssClass = "multicolumn-customize",
Fields = new UiDropDownFields { Text = "Name", Value = "Eimg" },
Columns = new List<UiDropDownColumn>
{
new UiDropDownColumn { Field = "Eimg", Header = "Photos", HeaderTemplate = "#hdrPhoto", Width = 90, Template = "#colPhoto" },
new UiDropDownColumn { Field = "Name", Header = "Employee Name", HeaderTemplate = "#hdrName", Width = 160, Template = "#colName" },
new UiDropDownColumn { Field = "DateofJoining", Header = "Date Of Joining", HeaderTemplate = "#hdrDate", Width = 165, Template = "#colDate" },
new UiDropDownColumn { Field = "Country", Header = "Country", HeaderTemplate = "#hdrCountry", Width = 100, Template = "#colCountry" }
},
DataSource = Model.Employees,
PopupHeight = "210px",
PopupWidth = "540px"
})
</div>
</div>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class MultiColumnComboBoxController : Controller
{
// The page is Views/MultiColumnComboBox/Template.cshtml; it draws what ViewData holds.
public ActionResult Template()
{
EmployeeViewModel model = new EmployeeViewModel();
model.Employees = GetEmployees();
return View(model);
}
public class EmployeeList
{
public string Name { get; set; }
public int Eimg { get; set; }
public string Designation { get; set; }
public string Country { get; set; }
public string DateofJoining { get; set; }
}
public class EmployeeViewModel
{
public List<EmployeeList> Employees { get; set; }
}
private static List<EmployeeList> GetEmployees()
{
return new List<EmployeeList>
{
new EmployeeList { Name = "Andrew Fuller", Eimg = 7, Designation = "Team Lead", Country = "England", DateofJoining = "2010/12/10" },
new EmployeeList { Name = "Anne Dodsworth", Eimg = 1, Designation = "Developer", Country = "USA", DateofJoining = "2000/10/05" },
new EmployeeList { Name = "Janet Leverling", Eimg = 3, Designation = "HR", Country = "Russia", DateofJoining = "2016/02/23" },
new EmployeeList { Name = "Laura Callahan", Eimg = 2, Designation = "Product Manager", Country = "Ukraine", DateofJoining = "2012/01/30" },
new EmployeeList { Name = "Margaret Peacock", Eimg = 6, Designation = "Developer", Country = "Egypt", DateofJoining = "2014/08/15" },
new EmployeeList { Name = "Michael Suyama", Eimg = 9, Designation = "Team Lead", Country = "Africa", DateofJoining = "2015/07/27" },
new EmployeeList { Name = "Nancy Davolio", Eimg = 4, Designation = "Product Manager", Country = "Australia", DateofJoining = "2017/05/24" },
new EmployeeList { Name = "Robert King", Eimg = 8, Designation = "Developer", Country = "India", DateofJoining = "2018/09/08" },
new EmployeeList { Name = "Steven Buchanan", Eimg = 10, Designation = "CEO", Country = "Ireland", DateofJoining = "2020/03/05" }
};
}
}
}
@* 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>
The MultiColumn ComboBox provides several options to customize each list items and column headers.
This sample uses the following list of templates in ComboBox
Template- To customize the MultiColumn ComboBox list item's content.HeaderTemplate- To customize the header element.