Skip to content

Commit e097292

Browse files
author
Kendo Bot
committed
Sync with Kendo UI Professional
1 parent 4893efb commit e097292

38 files changed

+2214
-395
lines changed

docs-aspnet-core/html-helpers/editors/autocomplete/binding.md

Lines changed: 0 additions & 97 deletions
This file was deleted.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: Ajax Binding
3+
page_title: Ajax Binding | Telerik UI AutoComplete HtmlHelper for ASP.NET Core
4+
description: "Learn how to implement Ajax Binding with Telerik UI AutoComplete HtmlHelper for ASP.NET Core (MVC 6 or ASP.NET Core MVC)."
5+
slug: htmlhelpers_autocomplete_ajaxbinding_aspnetcore
6+
position: 2
7+
---
8+
9+
# Ajax Binding
10+
11+
The AutoComplete provides support for remote data binding by using a `DataSource` configuration object. You can configure the AutoComplete to get its data from a remote source by making an AJAX request.
12+
13+
1. Create an action that returns the data as a JSON result.
14+
15+
public IActionResult Index()
16+
{
17+
return View(new ProductViewModel
18+
{
19+
ProductID = 4,
20+
ProductName = "ProductName4"
21+
});
22+
}
23+
24+
public JsonResult GetProductsAjax()
25+
{
26+
var products = Enumerable.Range(0, 500).Select(i => new ProductViewModel
27+
{
28+
ProductID = i,
29+
ProductName = "ProductName" + i
30+
});
31+
32+
return Json(products);
33+
}
34+
35+
1. Add the AutoComplete to the view and configure its DataSource to use remote data.
36+
37+
@model MvcApplication1.Models.ProductViewModel
38+
39+
@(Html.Kendo().AutoCompleteFor(m => m.ProductName)
40+
.Filter("contains")
41+
.DataTextField("ProductName")
42+
.Placeholder("Select product...")
43+
.DataSource(source =>
44+
{
45+
source.Read(read =>
46+
{
47+
read.Action("GetProductsAjax", "Home");
48+
})
49+
.ServerFiltering(false);
50+
})
51+
)
52+
53+
## See Also
54+
55+
* [Local Data Binding]({% slug htmlhelpers_autocomplete_serverbinding_aspnetcore %})
56+
* [Server-Side API](/api/dropdownlist)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: Overview
3+
page_title: Data Binding | Telerik UI AutoComplete HtmlHelper for ASP.NET Core
4+
description: "Learn the basics approaches for binding the Telerik UI AutoComplete HtmlHelper for ASP.NET Core (MVC 6 or ASP.NET Core MVC)."
5+
slug: htmlhelpers_autocomplete_databinding_aspnetcore
6+
position: 1
7+
---
8+
9+
# Data Binding
10+
11+
The AutoComplete provides a set of options for binding it to data.
12+
13+
The supported data-binding approaches are:
14+
15+
* [Ajax binding]({% slug htmlhelpers_autocomplete_ajaxbinding_aspnetcore %})
16+
* [Server binding]({% slug htmlhelpers_autocomplete_serverbinding_aspnetcore %})
17+
18+
## See Also
19+
20+
* [Server-Side API](/api/autocomplete)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: Server Binding
3+
page_title: Server Binding | Telerik UI AutoComplete HtmlHelper for ASP.NET Core
4+
description: "Learn how to implement server binding in the Telerik UI AutoComplete HtmlHelper for ASP.NET Core (MVC 6 or ASP.NET Core MVC)."
5+
slug: htmlhelpers_autocomplete_serverbinding_aspnetcore
6+
position: 3
7+
---
8+
9+
# Server Binding
10+
11+
Local data is the data that is available on the client when the AutoComplete is initialized.
12+
13+
You can bind the AutoComplete locally on the server by passing the appropriate collection to the HTML helper `BindTo()` method.
14+
15+
1. Pass the data to the view through `ViewData`.
16+
17+
public IActionResult Index()
18+
{
19+
ViewData["products"] = GetProducts();
20+
21+
return View(new ProductViewModel
22+
{
23+
ProductID = 4,
24+
ProductName = "ProductName4"
25+
});
26+
}
27+
28+
private static IEnumerable<ProductViewModel> GetProducts()
29+
{
30+
var products = Enumerable.Range(0, 2000).Select(i => new ProductViewModel
31+
{
32+
ProductID = i,
33+
ProductName = "ProductName" + i
34+
});
35+
36+
return products;
37+
}
38+
39+
1. Add the AutoComplete to the view and bind it to the data that is saved in `ViewData`.
40+
41+
@model MvcApplication1.Models.ProductViewModel
42+
43+
@(Html.Kendo().AutoCompleteFor(m => m.ProductName)
44+
.DataTextField("ProductName")
45+
.BindTo((System.Collections.IEnumerable)ViewData["products"])
46+
)
47+
48+
## See Also
49+
50+
* [Ajax Data Binding]({% slug htmlhelpers_autocomplete_ajaxbinding_aspnetcore %})
51+
* [Ajax Data Binding by the AutoComplete HtmlHelper for ASP.NET Core (Demo)](https://demos.telerik.com/aspnet-core/autocomplete/serverfiltering)
52+
* [Server-Side API](/api/dropdownlist)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: Grouping
3+
page_title: Grouping | Telerik UI AutoComplete HtmlHelper for ASP.NET Core
4+
description: "Learn how to group data in the Telerik UI AutoComplete HtmlHelper for ASP.NET Core works."
5+
slug: htmlhelpers_autocomplete_grouping_aspnetcore
6+
position: 2
7+
---
8+
9+
# Grouping Overview
10+
11+
The AutoComplete enables you to bind it to a grouped data source.
12+
13+
To group the data, define a group `datasource` expression which uses a custom DataSource configuration, and specify the field by which the AutoComplete will be grouped. For a runnable example, refer to the [demo on grouping in the AutoComplete](https://demos.telerik.com/aspnet-core/autocomplete/grouping).
14+
15+
> The data source sorts the grouped data either in ascending or descending order. To persist a specific group order, use the [server grouping feature](http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-serverGrouping). To define the `serverGrouping` option, use the `ServerGrouping` method of the DataSource.
16+
17+
The following example demonstrates how to group the data in the AutoComplete by country.
18+
19+
```
20+
@(Html.Kendo().AutoComplete()
21+
.Name("customers")
22+
.DataSource(source => source
23+
.Custom()
24+
.Group(g => g.Add("Country", typeof(string)))
25+
.Transport(transport => transport
26+
.Read(read =>
27+
{
28+
read.Action("Grouping_GetCustomers", "Home");
29+
}))
30+
)
31+
.DataTextField("ContactName")
32+
)
33+
```
34+
35+
## See Also
36+
37+
* [Grouping by the AutoComplete HtmlHelper for ASP.NET Core (Demo)](https://demos.telerik.com/aspnet-core/autocomplete/grouping)
38+
* [Server-Side API](/api/autocomplete)

docs-aspnet-core/html-helpers/editors/autocomplete/overview.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ The following example demonstrates how to define the AutoComplete by using the A
8080

8181
## Basic Configuration
8282

83-
The following example demonstrates the basic configuration of the AutoComplete HtmlHelper and how to get the AutoComplete instance.
83+
The following example demonstrates the basic configuration of the AutoComplete HtmlHelper.
8484

8585
```
8686
@(Html.Kendo().AutoComplete()
@@ -96,7 +96,6 @@ The following example demonstrates the basic configuration of the AutoComplete H
9696
.MinLength(3)
9797
.HtmlAttributes(new { style = "width:100%" })
9898
.Height(520)
99-
10099
.DataSource(source =>
101100
{
102101
source.Read(read =>
@@ -106,14 +105,6 @@ The following example demonstrates the basic configuration of the AutoComplete H
106105
})
107106
.ServerFiltering(true);
108107
})
109-
.Events(e => e
110-
.Change("onChange")
111-
.Select("onSelect")
112-
.Open("onOpen")
113-
.Close("onClose")
114-
.DataBound("onDataBound")
115-
.Filtering("onFiltering")
116-
)
117108
)
118109
119110
<script type="text/javascript">
@@ -122,25 +113,35 @@ The following example demonstrates the basic configuration of the AutoComplete H
122113
text: $("#autocomplete").val()
123114
};
124115
}
125-
126-
$(function () {
127-
// The Name() of the AutoComplete is used to get its client-side instance.
128-
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
129-
console.log(autocomplete);
130-
});
131116
</script>
132117
```
133118

134119
## Functionality and Features
135120

136-
* [Model binding]({% slug modelbinding_autocomplete_aspnetcore %})
121+
* [Data binding]({% slug htmlhelpers_autocomplete_databinding_aspnetcore %})
122+
* [Grouping]({% slug htmlhelpers_autocomplete_grouping_aspnetcore %})
123+
* [Templates]({% slug htmlhelpers_autocomplete_templates_aspnetcore %})
137124
* [Virtualization]({% slug virtualization_autocomplete_aspnetcore %})
138125
* [Accessibility]({% slug accessibility_aspnetcore_autocomplete %})
139126

140127
## Events
141128

142129
For a complete example on basic AutoComplete events, refer to the [demo on using the events of the AutoComplete](https://demos.telerik.com/aspnet-core/autocomplete/events).
143130

131+
## Referencing Existing Instances
132+
133+
To reference an existing AutoComplete instance, use the [`jQuery.data()`](https://api.jquery.com/jQuery.data/) configuration option. Once a reference is established, use the [AutoComplete API](https://docs.telerik.com/kendo-ui/api/javascript/ui/autocomplete) to control its behavior.
134+
135+
```
136+
// Place the following after your Telerik UI AutoComplete for ASP.NET Core declaration.
137+
<script>
138+
$(document).ready(function() {
139+
// The Name() of the AutoComplete is used to get its client-side instance.
140+
var autocomplete = $("#autocomplete").data("kendoAutoComplete");
141+
});
142+
</script>
143+
```
144+
144145
## See Also
145146

146147
* [Basic Usage of the AutoComplete HtmlHelper for ASP.NET Core (Demo)](https://demos.telerik.com/aspnet-core/autocomplete/index)

0 commit comments

Comments
 (0)