Skip to content

Commit b8f3549

Browse files
committed
Sync with Kendo UI Professional
1 parent 07bc57c commit b8f3549

File tree

4 files changed

+577
-0
lines changed

4 files changed

+577
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
title: Extending Kendo SVG Icons with Custom Ones
3+
description: Learn how to extend the Kendo UI for jQuery SVG icons library by creating and adding custom SVG icons.
4+
type: how-to
5+
page_title: How to Add Custom SVG Icons to Kendo UI for jQuery
6+
slug: extend-kendo-svg-icons-jquery
7+
tags: kendo, ui, jquery, svg, icons, custom, extend
8+
res_type: kb
9+
ticketid: 1670081
10+
---
11+
12+
## Description
13+
Creating custom SVG icons and extending the existing Kendo UI for jQuery SVG icons library is a straightforward process. This KB article demonstrates how to add a custom SVG icon to the list of available icons in Kendo UI for jQuery library.
14+
15+
This KB article also answers the following questions:
16+
- How can I add a custom icon to the Kendo UI for jQuery Icon library?
17+
- What is the process for creating a custom SVG icon in Kendo UI for jQuery?
18+
- Can I extend the Kendo UI SVG icons with custom designs?
19+
20+
## Environment
21+
<table>
22+
<tbody>
23+
<tr>
24+
<td>Product</td>
25+
<td>Kendo UI for jQuery</td>
26+
</tr>
27+
<tr>
28+
<td>Version</td>
29+
<td>2024.4.1112</td>
30+
</tr>
31+
</tbody>
32+
</table>
33+
34+
## Solution
35+
To create and use a custom SVG icon within the Kendo UI for jQuery, follow these steps:
36+
37+
1. Define the custom icon by specifying its `name`, `content`, and `viewBox`. The `content` should contain the SVG path data.
38+
39+
```javascript
40+
let myCustomIcon = {
41+
name: 'my-custom',
42+
content: '<path d="..."></path>', // Specify the SVG path data
43+
viewBox: '0 0 512 512' // Define the viewBox dimensions
44+
};
45+
```
46+
47+
2. Extend the `kendo.ui.svgIcons` object with the newly created custom icon.
48+
49+
```javascript
50+
kendo.ui.svgIcons = $.extend({ myCustomIcon }, kendo.ui.svgIcons);
51+
```
52+
53+
3. Reference the custom icon by its name (`my-custom` in this case).
54+
55+
Here is an example of how to use the custom icon in a Kendo Button:
56+
57+
```dojo
58+
<button id="button" type="button">
59+
<span class="k-icon"></span> Inbox
60+
</button>
61+
62+
<div id="toolbar"></div>
63+
64+
<script>
65+
let myCustomIcon = {
66+
name: 'my-custom',
67+
content: '<path d="M448 32H64c-17.7 0-32 14.3-32 32v384c0 17.7 14.3 32 32 32h384c17.7 0 32-14.3 32-32V64c0-17.7-14.3-32-32-32M256 448c-106 0-192-86-192-192S150 64 256 64s192 86 192 192-86 192-192 192m28-164.8c-82.9 28.9-118.1 83.4-126.7 98.7 27.2 21.3 61.5 34.1 98.7 34.1 22.5 0 43.9-4.6 63.3-13-3.3-18.4-13.1-65.2-34.2-120.1-.4 0-.8.2-1.1.3m-95.5-172.3c-44.9 20.9-78.5 62.1-89 111.8 17.1-.1 78.6-1.7 147.6-20-24.3-43.2-50.3-80.1-58.6-91.8m79 146.8c2.1-.7 4.3-1.3 6.5-2-4.1-9.3-8.6-18.6-13.3-27.8-74.1 22.2-146.1 23.4-164.6 23.4 0 1.6-.1 3.1-.1 4.7 0 40.8 15.3 78 40.4 106.3 10.5-16.7 54.6-79.9 131.1-104.6m94.9-121.1C334.2 111.3 296.9 96 256 96c-12.4 0-24.5 1.4-36 4.1 8.7 11.9 34.9 48.8 58.8 92.7 50.7-19 76-46.7 83.6-56.2m-46.6 138.7C335 328 344 371.9 346.9 387.8c35.2-24.3 60.2-62.5 67.2-106.6-13.2-3.7-53.4-13.1-98.3-5.9m-24.4-58.1c3.8 7.8 7.5 15.8 10.9 23.8 1.2 2.8 2.4 5.7 3.5 8.5 48-6 95.7 1.8 110.2 4.5-.5-37.2-13.7-71.4-35.4-98.3-8.4 10-36.1 39.8-89.2 61.5"></path>',
68+
viewBox: '0 0 512 512'
69+
};
70+
kendo.ui.svgIcons = $.extend({ myCustomIcon }, kendo.ui.svgIcons)
71+
72+
$("#button").kendoButton({
73+
icon: "my-custom"
74+
});
75+
76+
$("#toolbar").kendoToolBar({
77+
items: [
78+
{ type: "button", text: "foo", icon: "my-custom" },
79+
{ type: "button", text: "bar", icon: "info-circle" }
80+
]
81+
});
82+
</script>
83+
```
84+
85+
## See Also
86+
- [Kendo UI Icons Overview](https://docs.telerik.com/kendo-ui/styles-and-layout/icons-web)
87+
- [Kendo UI Icons API Documentation](https://docs.telerik.com/kendo-ui/api/javascript/ui/ui/methods/icon)
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
---
2+
title: Capturing Sort Events in Kendo UI Spreadsheet
3+
description: How to capture sort events in the Spreadsheet component when a user changes the sort order.
4+
type: how-to
5+
page_title: How to Implement Sort Event Handling in Kendo UI Spreadsheet
6+
slug: how-to-capture-sort-events-in-kendo-ui-spreadsheet
7+
tags: kendo-ui, spreadsheet, event-handling, sorting
8+
res_type: kb
9+
ticketid: 1669478
10+
---
11+
12+
## Environment
13+
14+
<table>
15+
<tbody>
16+
<tr>
17+
<td>Product</td>
18+
<td>Spreadsheet for Progress® Kendo UI®</td>
19+
</tr>
20+
<tr>
21+
<td>Version</td>
22+
<td>2024.3.1015</td>
23+
</tr>
24+
</tbody>
25+
</table>
26+
27+
## Description
28+
I need to trigger a sort event in the [Spreadsheet](https://docs.telerik.com/kendo-ui/api/javascript/ui/spreadsheet) component when a user changes the sort order by using the built-in sort feature. Currently, the Spreadsheet does not natively provide sort or filter events.
29+
30+
This KB article also answers the following questions:
31+
- How can I detect when a user sorts data in the Spreadsheet?
32+
- What approach can I use to capture sort actions in the Spreadsheet?
33+
- Is there a way to execute custom logic after sorting in the Spreadsheet?
34+
35+
## Solution
36+
To achieve the detection of sort events in the Spreadsheet when the user changes the sort order, you can handle the click event on the filter icons. Then, bind click event listeners to the sorting actions ('Sort from A to Z' and 'Sort from Z to A') and execute the necessary logic.
37+
38+
The following example demonstrates how to bind event listeners for sorting actions:
39+
40+
```javascript
41+
$('.k-spreadsheet-filter').on('click', function(){
42+
var current = this;
43+
$('li[data-dir="asc"]').click({param1: current}, function(ev){
44+
alert('Sort ASC');
45+
});
46+
47+
$('li[data-dir="desc"]').click({param1: current}, function(ev){
48+
alert('Sort DESC');
49+
});
50+
});
51+
```
52+
53+
The above code snippet captures both ascending and descending sort actions performed by the user and demonstrates a simple alert as a placeholder for any custom logic you might want to implement.
54+
55+
For a practical demonstration, refer to the example below:
56+
57+
```dojo
58+
<div id="spreadsheet" style="width: 100%"></div>
59+
<script>
60+
$(function() {
61+
var crudServiceBaseUrl = "https://demos.telerik.com/kendo-ui/service";
62+
63+
var dataSource = new kendo.data.DataSource({
64+
transport: {
65+
read: onRead,
66+
submit: onSubmit
67+
},
68+
batch: true,
69+
sort: {field: "ProductID", dir: 'desc'},
70+
schema: {
71+
model: {
72+
id: "ProductID",
73+
fields: {
74+
ProductID: { type: "number" },
75+
ProductName: { type: "string" },
76+
UnitPrice: { type: "number" },
77+
Discontinued: { type: "boolean" },
78+
UnitsInStock: { type: "number" }
79+
}
80+
}
81+
}
82+
});
83+
84+
$("#spreadsheet").kendoSpreadsheet({
85+
dataBound: function(){
86+
$('.k-spreadsheet-filter').on('click', function(){
87+
88+
var current = this;
89+
$('li[data-dir="asc"]').click({param1: current}, function(ev){
90+
alert('Sort ASC')
91+
})
92+
93+
$('li[data-dir="desc"]').click({param1: current}, function(ev){
94+
alert('Sort DESC')
95+
})
96+
})
97+
},
98+
columns: 20,
99+
rows: 100,
100+
toolbar: false,
101+
sheetsbar: false,
102+
sheets: [{
103+
name: "Products",
104+
dataSource: dataSource,
105+
filter: {
106+
ref: "A1:E79",
107+
columns:[]
108+
},
109+
rows: [{
110+
height: 40,
111+
cells: [
112+
{
113+
bold: "true",
114+
background: "#9c27b0",
115+
textAlign: "center",
116+
color: "white"
117+
},{
118+
bold: "true",
119+
background: "#9c27b0",
120+
textAlign: "center",
121+
color: "white"
122+
},{
123+
bold: "true",
124+
background: "#9c27b0",
125+
textAlign: "center",
126+
color: "white"
127+
},{
128+
bold: "true",
129+
background: "#9c27b0",
130+
textAlign: "center",
131+
color: "white"
132+
},{
133+
bold: "true",
134+
background: "#9c27b0",
135+
textAlign: "center",
136+
color: "white"
137+
}]
138+
}],
139+
columns: [
140+
{ width: 100 },
141+
{ width: 415 },
142+
{ width: 145 },
143+
{ width: 145 },
144+
{ width: 145 }
145+
]
146+
}]
147+
});
148+
149+
150+
151+
function onSubmit(e) {
152+
$.ajax({
153+
url: crudServiceBaseUrl + "/Products/Submit",
154+
data: { models: kendo.stringify(e.data) },
155+
contentType: "application/json",
156+
dataType: "jsonp",
157+
success: function (result) {
158+
e.success(result.Updated, "update");
159+
e.success(result.Created, "create");
160+
e.success(result.Destroyed, "destroy");
161+
},
162+
error: function (xhr, httpStatusMessage, customErrorMessage) {
163+
alert(xhr.responseText);
164+
}
165+
});
166+
}
167+
168+
function onRead(options) {
169+
$.ajax({
170+
url: crudServiceBaseUrl + "/Products",
171+
dataType: "jsonp",
172+
success: function (result) {
173+
options.success(result);
174+
},
175+
error: function (result) {
176+
options.error(result);
177+
}
178+
});
179+
}
180+
});
181+
</script>
182+
</div>
183+
```
184+
185+
## See Also
186+
187+
- [Kendo UI Spreadsheet Overview](https://docs.telerik.com/kendo-ui/controls/data-management/spreadsheet/overview)
188+
- [Kendo UI Spreadsheet API Reference](https://docs.telerik.com/kendo-ui/api/javascript/ui/spreadsheet)

0 commit comments

Comments
 (0)