组合框的概述

Telerik UI for ASP。网络核心Ninja image

ComboBox是Telerik UI for ASP。网络核心,一个具有 110+ 组件的专业级UI库,用于构建现代和功能丰富的 应用程序。想要试用它,可以注册一个30天的免费试用期。

Telerik UI ComboBox TagHelper和HtmlHelper。网络核心are server-side wrappers for the Kendo UI ComboBox widget.

组合框显示一个值列表,并允许从列表中进行单个选择。

初始化组合框

下面的示例演示如何定义组合框。

@(Html.Kendo(). combobox (). name ("combobox") . datatextfield ("ProductName") . datavaluefield ("ProductID") . datasource (source => {source. combobox (). name ("combobox") . datatextfield ("ProductName") . datasource (source => {读(读=>{读。行动(“Products_Read”、“组合框”);});}))
       .
公共类ComboBoxController: Controller {public IActionResult Index() {return View();} public JsonResult Products_Read() {var result =可枚举的。范围(0,50)。Select(i => new ProductViewModel {ProductID = "" + i, ProductName = "Product " + i});返回Json(结果);}}

基本配置

下面的示例演示了ComboBox的基本配置。

@(Html.Kendo().ComboBox() .Name("products") .占位符("选择产品").DataTextField("ProductName") .DataValueField("ProductID") .HtmlAttributes(new {style = "width:100%;"}) . filter (FilterType.Contains) . autobind (false) . minlength (3) . datasource (source => source . read (read => read。Action(“GetProducts”,“Home”))))
@addTagHelper *, <>   <传输> <读取url=”@Url。行动(“GetProducts”、“家”)”/>    .
public JsonResult GetProducts() {return new JsonResult(new[] {new {ProductName = "ProductName 1", ProductID = 1}});}

功能和特性

事件

你可以订阅所有的ComboBox事件.有关基本组合框事件的完整示例,请参阅关于使用组合框事件的演示

按处理程序名称处理

下面的示例演示如何通过处理程序名称订阅事件。

@(Html.Kendo().ComboBox() .Name("combobox") .BindTo(新字符串[]{"Item1", "Item2", "Item3"}) .Events(e => e .Select("combobox_select") .Change("combobox_change"))))
@{var items = new string[] {"Item 1", "Item 2", "Item 3"};}   .

模板委托处理

下面的示例演示如何通过模板委托订阅事件。

@(Html.Kendo(). combobox (). name ("combobox") . bindto(新字符串[]{"Item1", "Item2", "Item3"}) . events (e => e. select (@ function(){//内联处理选择事件。} ) . change (@ function(){//内联处理更改事件。} )))

另请参阅

在本文中
Baidu
map