Skip to content

Commit 357898a

Browse files
vveesseelliinnaapepinho24
authored andcommitted
docs(multiselect): Add Templates article
1 parent efd08cd commit 357898a

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed

controls/multiselect/functionality/templates.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,119 @@ tags: template,client
77
published: True
88
position: 1
99
---
10+
11+
# Templates
12+
13+
**RadMultiSelect** uses [Kendo UI Templates](https://docs.telerik.com/kendo-ui/framework/templates/overview) to provide full control over the rendering of items, selected values, and popup headers. The control supports the following templates:
14+
15+
- [Templates](#templates)
16+
- [Item template](#item-template)
17+
- [Tag Template](#tag-template)
18+
- [Header Template](#header-template)
19+
- [Footer Template](#footer-template)
20+
- [No Data Template](#no-data-template)
21+
- [See Also](#see-also)
22+
23+
>caption Figure 1: Structure of the popup and where you can use templates.
24+
25+
![multiselect template example](../images/multiselect-templates.png)
26+
27+
You can see the source code used for producing the image in [RadMultiSelect Templates Live demo](https://demos.telerik.com/aspnet-ajax/multiselect/customizingtemplates/defaultcs.aspx).
28+
29+
>caption Example 1: Sample use of templates in RadMultiSelect.
30+
31+
````ASP.NET
32+
<telerik:RadMultiSelect runat="server" Width="400px" ID="RadMultiSelect1"
33+
DataTextField="ContactName"
34+
DataValueField="CustomerID"
35+
DropDownHeight="400"
36+
CssClass="customers-wrapper"
37+
Placeholder="Select customers...">
38+
<ItemTemplate>
39+
<span class="k-state-default"><h3>#: data.ContactName #</h3><p>#: data.CompanyName #</p></span>
40+
</ItemTemplate>
41+
<TagTemplate>
42+
<span style="color:red;">#:data.ContactName#</span>
43+
</TagTemplate>
44+
<HeaderTemplate>
45+
<div style="color: darkgreen; font-size: 18px">
46+
<span>Photo</span>
47+
<span>Contact info</span>
48+
</div>
49+
</HeaderTemplate>
50+
<FooterTemplate>
51+
<div style="color: gray; font-size: 14px">
52+
Total #: instance.dataSource.total() # items found
53+
</div>
54+
</FooterTemplate>
55+
<NoDataTemplate>
56+
No data found. Please try searching for a different customer.
57+
</NoDataTemplate>
58+
59+
<WebServiceClientDataSource>
60+
<WebServiceSettings ServiceType="OData">
61+
<Select DataType="JSONP" Url="https://demos.telerik.com/kendo-ui/service/Northwind.svc/Customers" />
62+
</WebServiceSettings>
63+
</WebServiceClientDataSource>
64+
</telerik:RadMultiSelect>
65+
````
66+
67+
68+
## Item template
69+
70+
This is the template that is rendered in each individual column. It receives the `data` parameter that points to the dataItem for the corresponding item, so you can use all its data source fields
71+
72+
````ASP.NET
73+
<telerik:RadMultiSelect runat="server" Width="400px" ID="RadMultiSelect1"
74+
DataTextField="ContactName"
75+
DataValueField="CustomerID">
76+
<ItemTemplate>
77+
<span class="k-state-default" style="background-image: url('https://demos.telerik.com/kendo-ui/content/web/Customers/#:data.CustomerID#.jpg')"></span>
78+
<span class="k-state-default"><h3>#: data.ContactName #</h3><p>#: data.CompanyName #</p></span>
79+
</ItemTemplate>
80+
<WebServiceClientDataSource>
81+
<WebServiceSettings ServiceType="OData">
82+
<Select DataType="JSONP" Url="https://demos.telerik.com/kendo-ui/service/Northwind.svc/Customers" />
83+
</WebServiceSettings>
84+
</WebServiceClientDataSource>
85+
</telerik:RadMultiSelect>
86+
<style>
87+
.RadMultiSelectDropDown .k-item > span:first-child {
88+
width: 50px;
89+
height: 50px;
90+
border-radius: 50%;
91+
background-size: 100%;
92+
background-repeat: no-repeat;
93+
}
94+
</style>
95+
````
96+
97+
## Tag Template
98+
99+
This is the [https://docs.telerik.com/kendo-ui/api/javascript/ui/multiselect/configuration/tagtemplate](https://docs.telerik.com/kendo-ui/api/javascript/ui/multiselect/configuration/tagtemplate) that manages the way the tag of a MultiSelect is rendered. It is not bound to data and is static HTML.
100+
101+
## Header Template
102+
103+
A [https://docs.telerik.com/kendo-ui/api/javascript/ui/multiselect/configuration/headertemplate](https://docs.telerik.com/kendo-ui/api/javascript/ui/multiselect/configuration/headertemplate) that shows above all items. It is not bound to data and is static HTML.
104+
105+
>caution The header content should be wrapped with an HTML tag if it contains more than one element. This is applicable also when header content is just a string/text.
106+
>
107+
108+
## Footer Template
109+
110+
This is the [https://docs.telerik.com/kendo-ui/api/javascript/ui/multiselect/configuration/footertemplate](https://docs.telerik.com/kendo-ui/api/javascript/ui/multiselect/configuration/footertemplate) used to render the footer. The footer is re-rendered on every change of the Data Source. The context of the footer template is the underlying Kendo Widget itself that you can access through the `instance` argument.
111+
112+
## No Data Template
113+
114+
This [template](https://docs.telerik.com/kendo-ui/api/javascript/ui/multiselect/configuration/nodatatemplate) is shown when the data source is empty or the current filter operation returned no results.
115+
116+
>caution When the NoDataTemplate is defined, the MultiSelect always opens the popup element.
117+
>
118+
119+
120+
## See Also
121+
122+
* [Live Demo - Templates](http://demos.telerik.com/aspnet-ajax/multiselect/customizingtemplates/defaultcs.aspx)
123+
124+
* [Kendo UI MultiSelect Widget API Reference](https://docs.telerik.com/kendo-ui/api/javascript/ui/multiselect)
125+
42.2 KB
Loading

0 commit comments

Comments
 (0)