Skip to content

Commit 1abb5b8

Browse files
vveesseelliinnaapepinho24
authored andcommitted
docs(mulstiselect): Add Filtering article
1 parent 6a735fc commit 1abb5b8

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

controls/multiselect/functionality/filtering.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,72 @@ tags: filtering,client,server
77
published: True
88
position: 2
99
---
10+
11+
# Filtering
12+
13+
**RadMultiSelect** lets the user type a search query in the input and it will filter the data source so only relevant items are shown. By default, the filter operation is performed on the client, over the current data. You can also use [server filtering](#server-filtering).
14+
15+
To enable filtering set the `Filter` property to the desired filter operation:
16+
17+
* `Contains`
18+
* `StartsWith`
19+
* `EndsWith`
20+
21+
The `MinLength` property defines the minimum input length before the filter operation is performed.
22+
23+
>caution When you apply server filtering, only the source of **RadMultiSelect** is filtered. To page and filter the dataset, use the [virtualization]({%slug multiselect/functionality/virtualization%}) feature.
24+
>
25+
26+
>caption Example 1: Basic filtering in RadMultiSelect - the `name` field will be searchable
27+
28+
````ASP.NET
29+
<telerik:RadMultiSelect ID="RadMultiSelect1" runat="server" DataTextField="name" DataValueField="id" Width="400px"
30+
Filter="Contains" MinLength="3">
31+
<ClientEvents OnLoad="OnLoad" />
32+
</telerik:RadMultiSelect>
33+
<script>
34+
function OnLoad(sender, args) {
35+
var data = [
36+
{ id: 1, name: "Apples", fruitType: "regular" },
37+
{ id: 2, name: "Oranges", fruitType: "citrus" },
38+
{ id: 3, name: "Bananas", fruitType: "citrus" }
39+
];
40+
sender.get_kendoWidget().setDataSource(data);
41+
}
42+
</script>
43+
````
44+
45+
>tip Client filtering will work with both client-side and server-side binding. If used with a declarative data source, it will serialize its data to an array on the client, just like it would behave if the data was fetched from a web service call.
46+
47+
## Server Filtering
48+
49+
When you set the `WebServiceClientDataSource.EnableServerFiltering` property to `true`, filtering will request the data from the server.
50+
51+
This can be useful when there is a lot of data that would slow down the browser by creating a lot of elements, or would be costly to the server. Combined with `MinLength`, you can improve the performance for both the client, and the server.
52+
53+
The server filtering requires binding to a web service, and it will result in GET requests where querystring parameters will denote the filtered field and operator. For example, if the `ProductName` field is set as the `DataValueField`, `Filter` is `Contains` and the user input is `che`, the parameter added to the URL will look something like `&$filter=substringof('che',tolower(ProductName))"`.
54+
55+
With server filtering, **RadMultiSelect** will not request the data when initializing, only when the user types in a search string of sufficient length (see `MinLength`). This is done by setting the `autoBind` property of the underlying Kendo widget to `false`.
56+
57+
>caption Example 2: Enabling server filtering
58+
59+
````ASP.NET
60+
<telerik:RadMultiSelect runat="server" ID="RadMultiSelect2" Width="400px"
61+
DataTextField="ProductName"
62+
DataValueField="ProductID"
63+
Placeholder="Select products..."
64+
MinLength="3">
65+
<WebServiceClientDataSource runat="server" EnableServerFiltering="true">
66+
<WebServiceSettings ServiceType="OData">
67+
<Select Url="https://demos.telerik.com/kendo-ui/service/Northwind.svc/Products" />
68+
</WebServiceSettings>
69+
</WebServiceClientDataSource>
70+
</telerik:RadMultiSelect>
71+
````
72+
73+
## See Also
74+
75+
* [Live Demo - Server Filtering](http://demos.telerik.com/aspnet-ajax/multiselect/serverfiltering/defaultcs.aspx)
76+
77+
* [Kendo UI MultiSelect Widget API Reference](https://docs.telerik.com/kendo-ui/api/javascript/ui/multiselect)
78+

0 commit comments

Comments
 (0)