Example of filter in ASP.NET MVC MultiColumnComboBox Control
This sample demonstrates the built-in support to filter the Datasource in the MultiColumn ComboBox.
Choose filter type
@Html.UiMultiColumnComboBox("filtering", new UiMultiColumnComboBoxOptions
{
Placeholder = "e.g. Alice Johnson",
Fields = new UiDropDownFields { Text = "Name", Value = "Name" },
Columns = new List<UiDropDownColumn>
{
new UiDropDownColumn { Field = "Name", Header = "Name", Width = 100 },
new UiDropDownColumn { Field = "Department", Header = "Department", Width = 110 },
new UiDropDownColumn { Field = "Role", Header = "Role", Width = 140 },
new UiDropDownColumn { Field = "Location", Header = "Location", Width = 100 },
new UiDropDownColumn { Field = "Experience", Header = "Experience in Years", Width = 150 }
},
PopupHeight = "210px",
PopupWidth = "585px",
DataSource = (IEnumerable<DropdownsDemoController.Employee>)ViewData["data"]
})
@Html.UiDropDownList("filterType", new UiDropDownListOptions
{
Placeholder = "Select a filter type",
OnChange = "onChange",
PopupHeight = "200px",
PopupWidth = "300px",
Value = "StartsWith",
Items = new[] { "StartsWith", "EndsWith", "Contains" }.Select(text => new UiListItem(text, text)).ToList()
})
<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; }
</style>
@using Lumen.UI.Mvc.Demo.Controllers
<div class="control-section">
<div class="control-wrapper">
<label>Select an employee</label>
@Html.UiMultiColumnComboBox("filtering", new UiMultiColumnComboBoxOptions
{
Placeholder = "e.g. Alice Johnson",
Fields = new UiDropDownFields { Text = "Name", Value = "Name" },
Columns = new List<UiDropDownColumn>
{
new UiDropDownColumn { Field = "Name", Header = "Name", Width = 100 },
new UiDropDownColumn { Field = "Department", Header = "Department", Width = 110 },
new UiDropDownColumn { Field = "Role", Header = "Role", Width = 140 },
new UiDropDownColumn { Field = "Location", Header = "Location", Width = 100 },
new UiDropDownColumn { Field = "Experience", Header = "Experience in Years", Width = 150 }
},
PopupHeight = "210px",
PopupWidth = "585px",
DataSource = (IEnumerable<DropdownsDemoController.Employee>)ViewData["data"]
})
</div>
</div>
<div class="demo-property-panel" title="Properties">
<div class="demo-property-row">
<div>Choose filter type</div>
@Html.UiDropDownList("filterType", new UiDropDownListOptions
{
Placeholder = "Select a filter type",
OnChange = "onChange",
PopupHeight = "200px",
PopupWidth = "300px",
Value = "StartsWith",
Items = new[] { "StartsWith", "EndsWith", "Contains" }.Select(text => new UiListItem(text, text)).ToList()
})
</div>
</div>
<script>
// Syncfusion: the list sets the filterType of the MultiColumnComboBox.
function onChange(value) { if (value) { window.Lumen.get('filtering').setFilterType(value); } }
</script>
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/Filtering.cshtml; it draws what ViewData holds.
public ActionResult Filtering()
{
ViewData["data"] = new Employee().GetAllRecords();
return View();
}
public class Employee
{
public string Name { get; set; }
public string Department { get; set; }
public string Role { get; set; }
public string Location { get; set; }
public int Experience { get; set; }
public List<Employee> GetAllRecords()
{
List<Employee> Employee = new List<Employee>();
Employee.Add(new Employee { Name = "Alice Johnson", Department = "Engineering", Role = "Software Engineer", Location = "New York", Experience = 5});
Employee.Add(new Employee { Name = "Bob Smith", Department = "Marketing", Role = "Marketing Manager", Location = "San Francisco", Experience = 7});
Employee.Add(new Employee { Name = "Catherine Lee", Department = "Finance", Role = "Financial Analyst", Location = "Chicago", Experience = 4});
Employee.Add(new Employee { Name = "David Kim", Department = "Engineering", Role = "DevOps Engineer", Location = "Austin", Experience = 6});
Employee.Add(new Employee { Name = "Eva Brown", Department = "Sales", Role = "Sales Executive", Location = "Boston", Experience = 3});
Employee.Add(new Employee { Name = "Frank White", Department = "Human Resources", Role = "HR Manager", Location = "Seattle", Experience = 8});
Employee.Add(new Employee { Name = "Grace Green", Department = "Design", Role = "UX Designer", Location = "Los Angeles", Experience = 5});
Employee.Add(new Employee { Name = "Hank Wilson", Department = "Engineering", Role = "Front-end Developer", Location = "Denver", Experience = 4});
return Employee;
}
}
}
}
@* 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 supports filtering, which allows users to search for and select items by typing keywords. The available items are dynamically filtered based on the input, ensuring quick access to the desired data.