ASP。. NET Core下拉列表概述

面向ASP的Telerik UI。网络核心Ninja image

下拉列表是面向ASP的Telerik UI。网络核心一个专业级的UI库,包含 110+ 组件,用于构建现代和功能丰富的 应用程序。要想尝试一下,注册一个30天的免费试用。

Telerik UI下拉列表TagHelper和HtmlHelper网络核心are server-side wrappers for the Kendo UI DropDownList widget.

DropDownList显示一个值列表,并允许从列表中进行单个选择。用户输入被限制在预定义的选项中。

初始化下拉列表

下面的示例演示如何定义DropDownList。

@(Html.Kendo(). dropdownlist (). name ("dropdownlist") . datatextfield ("ProductName") . datavaluefield ("ProductID") . datasource (source => {source。读取(Read =>{读取。行动(“Products_Read”,“它”);});}))
   public class DropDownListController: Controller {public IActionResult Index() {return View();}公共JsonResult Products_Read() {var result = Enumerable。范围(0,50)。Select(i => new ProductViewModel {ProductID = "" + i, ProductName = "Product " + i});返回Json(结果);}}

基本配置

DropDownList配置选项作为属性传递。

@(Html.Kendo().DropDownList() .Name("products") .DataTextField("ProductName") .DataValueField("ProductID") .HtmlAttributes(new {style = "width:100%;")}) . filter (FilterType.Contains) . datasource (source => source . read (read => read。操作(“GetProducts”,“Home”))))
   
public JsonResult GetProducts(字符串文本){using (var northwind = GetContext()) {var products = northwind. products。选择(product => new ProductViewModel {ProductID = product。ProductID, ProductName = product。ProductName, UnitPrice = product.UnitPrice。Value, UnitsInStock = product.UnitsInStock。Value, UnitsOnOrder = product.UnitsOnOrder。价值,停产=产品。停止});if (!string.IsNullOrEmpty(text)){产品=产品。Where(p => p. productname . contains (text));}返回Json(products.ToList());}}

功能和特性

  • 绑定下拉列表支持多种数据绑定方法:服务器绑定、模型绑定、自定义绑定和ajax绑定。
  • 分组-可以将下拉列表绑定到分组数据源。
  • 虚拟化—下拉列表的虚拟化特性允许您显示大型数据集。
  • 模板要控制项目、所选值或弹出标题的呈现方式,可以使用可用的模板。
  • 可访问性-下拉列表可通过屏幕阅读器访问,并提供WAI-ARIA, Section 508, WCAG 2.1和键盘支持。

下一个步骤

另请参阅

在本文中
Baidu
map