Example of Default Functionalities in ASP.NET MVC MultiColumnComboBox Control
This sample demonstrates the default functionalities of the MultiColumn ComboBox.
| Value | : |
| Text | : |
@Html.UiMultiColumnComboBox("multicolumnDefault", new UiMultiColumnComboBoxOptions
{
Placeholder = "Select any product",
ShowClearButton = true,
Fields = new UiDropDownFields { Text = "Name", Value = "Name" },
Columns = new List<UiDropDownColumn>
{
new UiDropDownColumn { Field = "Name", Header = "Name", Width = 110 },
new UiDropDownColumn { Field = "Price", Header = "Price", Width = 85 },
new UiDropDownColumn { Field = "Availability", Header = "Availability", Width = 98 },
new UiDropDownColumn { Field = "Category", Header = "Category", Width = 95 },
new UiDropDownColumn { Field = "Rating", Header = "Rating", Width = 70 }
},
PopupHeight = "220px",
PopupWidth = "500px",
OnChange = "valueChange",
Value = "Smartphone",
DataSource = (IEnumerable<DropdownsDemoController.Products>)ViewData["data"]
})
<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; }
.demo-property-panel .right-side { padding-left: 10px; }
.demo-property-panel .left-side { padding: 5px; width: 25%; }
</style>
@using Lumen.UI.Mvc.Demo.Controllers
<div class="control-section">
<div class="control-wrapper">
<label>Select a product</label>
@Html.UiMultiColumnComboBox("multicolumnDefault", new UiMultiColumnComboBoxOptions
{
Placeholder = "Select any product",
ShowClearButton = true,
Fields = new UiDropDownFields { Text = "Name", Value = "Name" },
Columns = new List<UiDropDownColumn>
{
new UiDropDownColumn { Field = "Name", Header = "Name", Width = 110 },
new UiDropDownColumn { Field = "Price", Header = "Price", Width = 85 },
new UiDropDownColumn { Field = "Availability", Header = "Availability", Width = 98 },
new UiDropDownColumn { Field = "Category", Header = "Category", Width = 95 },
new UiDropDownColumn { Field = "Rating", Header = "Rating", Width = 70 }
},
PopupHeight = "220px",
PopupWidth = "500px",
OnChange = "valueChange",
Value = "Smartphone",
DataSource = (IEnumerable<DropdownsDemoController.Products>)ViewData["data"]
})
</div>
</div>
<div class="demo-property-panel" title="Properties">
<table id="property" style="width: 100%; margin:10px">
<tr><td class="left-side">Value</td><td>:<span id="value" class="right-side"></span></td></tr>
<tr><td class="left-side">Text</td><td>:<span id="text" class="right-side"></span></td></tr>
</table>
</div>
<script>
// Syncfusion: the panel shows the value and the text of the chosen row.
function valueChange() {
var value = window.Lumen.get('multicolumnDefault').getValue();
document.getElementById('value').innerHTML = value ? value.toString() : 'null';
var text = document.getElementById('multicolumnDefault').value;
document.getElementById('text').innerHTML = text ? text : 'null';
}
window.addEventListener('load', function () { setTimeout(valueChange, 0); });
</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/DefaultFunctionalities.cshtml; it draws what ViewData holds.
public ActionResult DefaultFunctionalities()
{
ViewData["data"] = new Products().GetAllRecords();
return View();
}
public class Products
{
public string Name { get; set; }
public string Price { get; set; }
public string Availability { get; set; }
public string Category { get; set; }
public double Rating { get; set; }
public List<Products> GetAllRecords()
{
List<Products> products = new List<Products>();
products.Add(new Products { Name = "Laptop", Price = "999.99m", Availability = "In Stock", Category = "Electronics", Rating = 4.5 });
products.Add(new Products { Name = "Smartphone", Price = "599.99m", Availability = "Out of Stock", Category = "Electronics", Rating = 4.3 });
products.Add(new Products { Name = "Tablet", Price = "299.99m", Availability = "In Stock", Category = "Electronics", Rating = 4.2 });
// ... 17 more rows
return products;
}
}
}
}
@* 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 allows the user to display detailed information about employees in multiple columns. In the above sample, type any character in the MultiColumn ComboBox or click the dropdown icon to choose an employee from the options available in the list. The selected item's Value and Text property values will be shown in the property panel.