Skip to content

Commit f4adf8d

Browse files
committed
Sync with Kendo UI Professional
1 parent e4555d6 commit f4adf8d

File tree

5 files changed

+393
-50
lines changed

5 files changed

+393
-50
lines changed

docs/knowledge-base/grid-how-to-change-multi-checkbox-filter-to-contains.md

Lines changed: 89 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,96 @@ $("#grid").kendoGrid({
8080
</script>
8181
```
8282

83-
## Additional Requirements
83+
## Additional Scenarios
8484

85-
I would like to keep the filter state active and show the applied initial filter on the grid.
85+
1. I would like to use `contains` instead of `equalTo` filter in multiple columns. When the [Column Menu](https://docs.telerik.com/kendo-ui/controls/grid/columns/column-menu) is enabled after filtering and opening the column filter again, the checkbox is not selected and shows unchecked. How I can check again the selected values in the filter popup?
8686

87-
## Suggested solution
87+
### Suggested solution
88+
89+
```dojo
90+
<div id="grid"></div>
91+
<script>
92+
$(document).ready(function () {
93+
$("#grid").kendoGrid({
94+
dataSource: {
95+
type: "odata",
96+
transport: {
97+
read: "https://demos.telerik.com/kendo-ui/service/Northwind.svc/Orders"
98+
},
99+
schema: {
100+
model: {
101+
fields: {
102+
OrderID: { type: "number" },
103+
ShipCountry: { type: "string" },
104+
ShipName: { type: "string" },
105+
ShipAddress: { type: "string" }
106+
}
107+
}
108+
},
109+
pageSize: 30
110+
},
111+
height: 550,
112+
sortable: true,
113+
filterable: true,
114+
columnMenu: true,
115+
filter: function(e){
116+
if(e.field == "OrderID" && e.filter){
117+
e.filter.filters.forEach(function(f){
118+
f.operator = "contains";
119+
})
120+
}
121+
},
122+
columnMenuOpen: function(e){
123+
if(e.sender.dataSource.filter()){
124+
e.sender.dataSource.filter().filters.forEach(function(f){
125+
126+
if(f.field == "OrderID" || f.field == 'ShipCountry') {
127+
var checkbox = e.container.find("input[value='"+f.value+"']");
128+
if(checkbox[0] && !checkbox[0].checked){
129+
e.container.find("input[value='"+f.value+"']").click()
130+
}
131+
}else if(f.filters[0].field == "OrderID" || f.filters[0].field == 'ShipCountry'){
132+
var current = f.filters;
133+
134+
current.forEach(function(filter){
135+
var checkbox2 = e.container.find("input[value='"+filter.value+"']");
136+
137+
if(checkbox2.length > 0 && !checkbox2[0].checked){
138+
e.container.find("input[value='"+filter.value+"']").click()
139+
}
140+
})
141+
}
142+
})
143+
}
144+
},
145+
pageable: true,
146+
columns: [{
147+
field: "OrderID",
148+
filterable: {
149+
multi:true,
150+
dataSource: [ { OrderID: 255 }, { OrderID: 25 }, { OrderID: 26 } ]
151+
}
152+
} ,{
153+
field: "ShipName",
154+
title: "Ship Name",
155+
width: 300
156+
},{
157+
field: "ShipCountry",
158+
title: "Ship Country",
159+
width: 300,
160+
filterable: {
161+
multi:true
162+
}
163+
}]
164+
});
165+
});
166+
</script>
167+
```
168+
169+
170+
2. I would like to keep the filter state active and show the applied initial filter on the grid.
171+
172+
### Suggested solution
88173

89174
It is easiest to add the `k-active` class initially and let the grid with the custom filter handler manage the rest of the state changes.A timeout is needed to accomplish this initial load:
90175

@@ -96,7 +181,7 @@ It is easiest to add the `k-active` class initially and let the grid with the cu
96181
});
97182
```
98183

99-
### Example
184+
#### Example
100185

101186
```dojo
102187
<div id="example">
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: Destroying Iframe Content in a Tooltip When Hidden
3+
description: Learn how to remove or destroy the iframe content of a Kendo UI for jQuery Tooltip when it is hidden.
4+
type: how-to
5+
page_title: How to Destroy Iframe Content in Kendo UI Tooltip on Hide
6+
slug: how-to-destroy-iframe-tooltip-content-kendo-ui
7+
tags: kendo, ui, jquery, tooltip, destroy, iframe, content, hide
8+
res_type: kb
9+
ticketid: 1682358
10+
---
11+
12+
## Environment
13+
14+
<table>
15+
<tbody>
16+
<tr>
17+
<td>Product</td>
18+
<td>Progress® Kendo UI® Tooltip</td>
19+
</tr>
20+
<tr>
21+
<td>Version</td>
22+
<td>2025.1.227</td>
23+
</tr>
24+
</tbody>
25+
</table>
26+
27+
## Description
28+
29+
I noticed that when a tooltip iframe is hidden, it still actually exists in the HTML code. The URL I open with the tooltip is active, and I would like to stop the activity of this page when the tooltip hides. Therefore, I need the iframe to be destroyed or its content to be removed when the tooltip is hidden. How can I achieve this?
30+
31+
This knowledge base article also answers the following questions:
32+
- How do I stop an iframe from loading content when the tooltip is hidden?
33+
- How can I remove the iframe content of a tooltip upon hiding?
34+
35+
## Solution
36+
37+
To remove or destroy the iframe content of a [Tooltip](https://docs.telerik.com/kendo-ui/api/javascript/ui/tooltip) when it is hidden, handle the [`hide`](/api/javascript/ui/tooltip/events/hide) event of the Tooltip and modify the `src` attribute of the iframe to an empty string. Additionally, during the [`show`](/api/javascript/ui/tooltip/events/show) event, you can set the `src` attribute of the iframe to the desired URL.
38+
39+
Below is an example demonstrating how to implement this behavior:
40+
41+
```dojo
42+
<span id="target" title="Tooltip content"> Some content </span>
43+
44+
<script>
45+
$(document).ready(function () {
46+
$("#target").kendoTooltip({
47+
iframe: true,
48+
content: {
49+
url: "https://demos.telerik.com/kendo-ui/content/web/tooltip/ajax/ajaxContent3.html",
50+
},
51+
hide: function(e){
52+
$('.k-content-frame').attr('src', '')
53+
},
54+
show: function(){
55+
$('.k-content-frame').attr('src', 'https://www.google.com/maps/embed')
56+
57+
},
58+
width: 220,
59+
height: 280,
60+
requestStart: function (e) {
61+
e.options.url = "https://www.google.com/maps/embed";
62+
},
63+
});
64+
});
65+
</script>
66+
```
67+
68+
In this solution, the `hide` event handler sets the `src` attribute of the iframe (selected by the `.k-content-frame` class) to an empty string, effectively removing its content. The `show` event handler resets the `src` attribute to the desired content URL each time the tooltip is shown.
69+
70+
## See Also
71+
72+
- [Tooltip Hide Event Documentation](https://docs.telerik.com/kendo-ui/api/javascript/ui/tooltip/events/hide)
73+
- [Tooltip Show Event Documentation](https://docs.telerik.com/kendo-ui/api/javascript/ui/tooltip/events/show)
74+
- [Tooltip API Reference](https://docs.telerik.com/kendo-ui/api/javascript/ui/tooltip)
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
---
2+
title: Iterating and Checking Items in Kendo UI for jQuery Grid FilterMultiCheck
3+
description: Learn how to programmatically iterate through and check items in a Kendo UI for jQuery Grid FilterMultiCheck component.
4+
type: how-to
5+
page_title: Programmatically Check Items in Kendo UI for jQuery Grid FilterMultiCheck
6+
slug: iterate-check-items-kendo-ui-jquery-grid-filtermulticheck
7+
tags: kendo, ui, jquery, grid, filtermulticheck, iterate, check, items
8+
res_type: kb
9+
ticketid: 1682081
10+
---
11+
12+
## Environment
13+
14+
<table>
15+
<tbody>
16+
<tr>
17+
<td>Product</td>
18+
<td>Kendo UI for jQuery Grid</td>
19+
</tr>
20+
<tr>
21+
<td>Version</td>
22+
<td>2025.1.227</td>
23+
</tr>
24+
</tbody>
25+
</table>
26+
27+
## Description
28+
29+
It is necessary to iterate through a Kendo UI for jQuery Grid FilterMultiCheck component and manually check items based on their text or value. How can this be achieved since Kendo UI does not provide a built-in method for directly modifying the selected checkboxes within the FilterMultiCheck?
30+
31+
This knowledge base article also answers the following questions:
32+
- How to programmatically select checkboxes in a Kendo UI for jQuery Grid FilterMultiCheck?
33+
- How to automatically check specific items in FilterMultiCheck based on their values?
34+
- How can I manipulate the checked state of items in a FilterMultiCheck component?
35+
36+
## Solution
37+
38+
To iterate and manually check items in a Kendo UI for jQuery Grid FilterMultiCheck component based on their text or value, follow the steps outlined below. Note that while Kendo UI does not support direct manipulation of checkboxes within the FilterMultiCheck, you can achieve the desired result by using jQuery to target the checkboxes after the filter menu has rendered. This can be done in the [`filterMenuInit`](https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/events/filtermenuinit) event handler.
39+
40+
1. Subscribe to the [`filterMenuInit`](https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/events/filtermenuinit) event of the Kendo UI for jQuery Grid.
41+
42+
2. Verify the field being filtered matches your criteria (e.g., 'UnitPrice' or 'UnitsInStock').
43+
44+
3. Use jQuery to find the filter menu for the specific field and obtain a reference to it.
45+
46+
4. Define the values that should be checked within the filter menu.
47+
48+
5. Loop through each checkbox in the filter menu and check those whose associated label values match the predefined values.
49+
50+
```javascript
51+
filterMenuInit: function (e) {
52+
// Check if the field being filtered is either 'UnitPrice' or 'UnitsInStock'
53+
if (e.field === "UnitPrice" || e.field === "UnitsInStock") {
54+
// Find the filter menu for the specific field (UnitPrice or UnitsInStock) using the header's data-field attribute
55+
let filterMenu = this.thead.find("[data-field=" + e.field + "]").data("kendoFilterMultiCheck");
56+
// Define an array of values that should be checked in the filter menu
57+
let valuesToCheck = [18, 40];
58+
59+
if (filterMenu) {
60+
// Loop through each checkbox input inside the filter menu
61+
$(".k-multicheck-wrap input[type='checkbox']").each(
62+
function () {
63+
// Get the label value next to the checkbox, remove the dollar sign, and convert it to a float
64+
var label = parseFloat(
65+
$(this).parent().next("span").text().replace("$", ""),
66+
);
67+
68+
// Check if the label value is included in the 'valuesToCheck' array
69+
if (valuesToCheck.includes(label)) {
70+
$(this).prop("checked", true);
71+
}
72+
},
73+
);
74+
}
75+
}
76+
},
77+
```
78+
79+
For a practical implementation, refer to the below runnable demo: [Kendo UI for jQuery Grid FilterMultiCheck Demo]
80+
81+
```dojo
82+
<div id="client"></div>
83+
<script>
84+
$(document).ready(function () {
85+
var telerikWebServiceBase =
86+
"https://demos.telerik.com/kendo-ui/service/";
87+
$("#client").kendoGrid({
88+
dataSource: {
89+
transport: {
90+
read: {
91+
url: telerikWebServiceBase + "/Products",
92+
dataType: "jsonp",
93+
},
94+
parameterMap: function (options, operation) {
95+
if (operation !== "read" && options.models) {
96+
return { models: kendo.stringify(options.models) };
97+
}
98+
},
99+
},
100+
batch: true,
101+
pageSize: 20,
102+
schema: {
103+
model: {
104+
id: "ProductID",
105+
fields: {
106+
ProductID: { editable: false, nullable: true },
107+
ProductName: { validation: { required: true } },
108+
UnitPrice: {
109+
type: "number",
110+
validation: { required: true, min: 1 },
111+
},
112+
Discontinued: { type: "boolean" },
113+
UnitsInStock: {
114+
type: "number",
115+
validation: { min: 0, required: true },
116+
},
117+
},
118+
},
119+
},
120+
},
121+
filterMenuInit: function (e) {
122+
// Check if the field being filtered is either 'UnitPrice' or 'UnitsInStock'
123+
if (e.field === "UnitPrice" || e.field === "UnitsInStock") {
124+
// Find the filter menu for the specific field (UnitPrice or UnitsInStock) using the header's data-field attribute
125+
let filterMenu = this.thead.find("[data-field=" + e.field + "]").data("kendoFilterMultiCheck");
126+
// Define an array of values that should be checked in the filter menu
127+
let valuesToCheck = [18, 40];
128+
129+
if (filterMenu) {
130+
// Loop through each checkbox input inside the filter menu
131+
$(".k-multicheck-wrap input[type='checkbox']").each(
132+
function () {
133+
// Get the label value next to the checkbox, remove the dollar sign, and convert it to a float
134+
var label = parseFloat(
135+
$(this).parent().next("span").text().replace("$", ""),
136+
);
137+
138+
// Check if the label value is included in the 'valuesToCheck' array
139+
if (valuesToCheck.includes(label)) {
140+
$(this).prop("checked", true);
141+
}
142+
},
143+
);
144+
}
145+
}
146+
},
147+
filterable: true,
148+
pageable: true,
149+
height: 550,
150+
toolbar: ["create", "save", "cancel"],
151+
columns: [
152+
{ field: "ProductName", filterable: { multi: true } },
153+
{
154+
field: "UnitPrice",
155+
title: "Unit Price",
156+
format: "{0:c}",
157+
width: 120,
158+
filterable: { multi: true },
159+
},
160+
{
161+
field: "UnitsInStock",
162+
title: "Units In Stock",
163+
width: 120,
164+
filterable: { multi: true },
165+
},
166+
{
167+
field: "Discontinued",
168+
width: 120,
169+
filterable: {
170+
multi: true,
171+
dataSource: [{ Discontinued: true }, { Discontinued: false }],
172+
},
173+
}
174+
]
175+
});
176+
});
177+
</script>
178+
```
179+
180+
## See Also
181+
182+
- [Kendo UI for jQuery Grid Documentation](https://docs.telerik.com/kendo-ui/controls/grid/overview)
183+
- [Grid API Reference](https://docs.telerik.com/kendo-ui/api/javascript/ui/grid)
184+

0 commit comments

Comments
 (0)