组合框的概述

Telerik UI for ASP。NET MVC忍者图像

组合框是Telerik UI for ASP。NET MVC,一个具有 110+ 组件的专业级UI库,用于构建现代和功能丰富的 应用程序。想要试用它,请注册一个30天的免费试用。

Telerik UI ComboBox HtmlHelper for ASP。NET MVCis a server-side wrapper for the Kendo UI ComboBox widget.

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

初始化组合框

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

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

基本配置

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

@(Html.Kendo(). combobox (). name ("combobox") . datatextfield ("ProductName") . datavaluefield ("ProductID") . htmlattributes (new {style = "width:100%"}) . filter ("contains") . minlength (3) . height (290) . headertemplate (" 
" + "Products" + "
items found") . footertemplate ("Total #: instance.dataSource.total() # items found") . datasource (source => {source. name ") . datatextfield ("ProductName") . datavaluefield ("ProductID") . htmlattributes (new {style = "width:100%").读(读=>{读。行动(“Products_Read2”,“它”);}) .ServerFiltering(假);}) . events (e => e. change ("onChange") . select ("onSelect") . open ("onOpen") . close ("onClose") . databound ("onDataBound") . filtering ("onFiltering"))

模板委托处理

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

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

另请参阅

在本文中
Baidu
map