Skip to content

Commit 71bd69c

Browse files
committed
Sync with Kendo UI Professional
1 parent d61317a commit 71bd69c

File tree

8 files changed

+224
-21
lines changed

8 files changed

+224
-21
lines changed

docs-aspnet/html-helpers/data-management/pivotgrid/overview.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ The PivotGrid represents multidimensional data in a cross-tabular format.
2929
* [Demo page for the PivotGrid TagHelper](https://demos.telerik.com/aspnet-core/pivotgrid/tag-helper)
3030
{% endif %}
3131

32+
> The new PivotGridV2 is now available. It offers a brand new design and a new future-proof architecture that allows the implementation of many upcoming functionalities. As PivotGridV2 aims to replace the legacy PivotGrid, it is recommended to use the PivotGridV2 in your new projects. For information about the differences between the PivotGrid and PivotGridV2, refer to the [Comparison]({% slug htmlhelpers_pivotgridv2_aspnetcore_comparison %}) article.
33+
3234
## Basic Configuration
3335

3436
To configure the PivotGrid for Ajax binding to an [Adventure Works](https://learn.microsoft.com/en-us/analysis-services/multidimensional-tutorial/multidimensional-modeling-adventure-works-tutorial?view=asallproducts-allversions) cube that is hosted on `https://demos.telerik.com/olap/msmdpump.dll`, follow the next steps:

docs/knowledge-base/chart-hide-navigator-during-export.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ To maintain the navigator settings after it was zoomed in or out:
113113
field: "Close"
114114
},
115115
select: {
116-
from: "2009/02/05",
117-
to: "2011/10/07"
116+
from: "2021/02/05",
117+
to: "2023/10/07"
118118
}
119119
}
120120
});
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
title: Disabling Drag and Drop for a Specific Column in Spreadsheet
3+
description: Learn how to prevent drag and drop functionality for a specific column in the Kendo UI for jQuery Spreadsheet.
4+
type: how-to
5+
page_title: How to Disable Drag and Drop for Specific Columns in Kendo UI Spreadsheet
6+
slug: disable-drag-drop-specific-column-spreadsheet
7+
tags: kendo-ui, spreadsheet, drag-and-drop, disable-functionality
8+
res_type: kb
9+
ticketid: 1671669
10+
---
11+
12+
## Environment
13+
14+
<table>
15+
<tbody>
16+
<tr>
17+
<td>Product</td>
18+
<td>Progress® Kendo UI for jQuery® Spreadsheet</td>
19+
</tr>
20+
</tbody>
21+
</table>
22+
23+
## Description
24+
25+
In some cases, you may want to restrict the drag and drop functionality for a specific column in the Kendo UI for jQuery Spreadsheet. This is to prevent users from accidentally or intentionally modifying data in columns that should remain static.
26+
27+
This knowledge base article also answers the following questions:
28+
- How can I disable auto-fill for a particular column in the Spreadsheet?
29+
- What approach should I take to prevent dragging of cells in a specified column?
30+
31+
## Solution
32+
33+
To disable drag and drop for a specific column in the Spreadsheet, handle the [changing](https://docs.telerik.com/kendo-ui/api/javascript/ui/spreadsheet/events/changing) event. Within the event handler, verify if the action is an auto-fill operation and if it originates from the column you wish to restrict. If both conditions are met, prevent the default behavior using `e.preventDefault()`. Below is an example that disables drag and drop for the second column (Column B).
34+
35+
```javascript
36+
changing: function(e){
37+
var range = e.range._sheet._autoFillOrigin;
38+
// Check if the operation is auto-fill and if it originates from column B (index 1)
39+
if(e.changeType == 'autoFill' && range.bottomRight.col == 1 && range.topLeft.col == 1) {
40+
alert('Dragging column B is prevented');
41+
e.preventDefault();
42+
}
43+
},
44+
```
45+
46+
Implement this logic in your application to effectively disable drag and drop for the specified column. Ensure to attach this event handler correctly to your Spreadsheet instance.
47+
48+
Explore a live example where dragging column B does not change the Spreadsheet's cell data: [Dojo example](https://dojo.telerik.com/kbqwNFgm).
49+
50+
## See Also
51+
52+
- [Spreadsheet Changing Event Documentation](https://docs.telerik.com/kendo-ui/api/javascript/ui/spreadsheet/events/changing)
53+
- [Kendo UI for jQuery Spreadsheet Overview](https://docs.telerik.com/kendo-ui/controls/spreadsheet/overview)

docs/knowledge-base/export-multiple-charts-in-the-same-pdf-file.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ How can I export many Charts in the same PDF file?
231231
field: "Close"
232232
},
233233
select: {
234-
from: "2009/02/05",
235-
to: "2011/10/07"
234+
from: "2021/02/05",
235+
to: "2023/10/07"
236236
}
237237
}
238238
});

docs/knowledge-base/how-to-display-chart-data-zoomed-to-last-30-days.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,12 @@ For an interactive example using the [`Stock Chart`](https://docs.telerik.com/ke
181181
field: "Close"
182182
},
183183
select: {
184-
from: "2011/12/01",
185-
to: "2011/12/31"
184+
from: "2023/12/01",
185+
to: "2023/12/31"
186186
},
187187
categoryAxis: {
188-
max: "2011/12/31",
189-
min: "2011/01/01"
188+
max: "2023/12/31",
189+
min: "2023/01/01"
190190
}
191191
}
192192
});
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
title: Setting Cell Background Color in Kendo UI for jQuery Grid
3+
description: Learn how to dynamically set the background color of Grid cells based on data source fields in Kendo UI for jQuery Grid.
4+
type: how-to
5+
page_title: How to Set Grid Cell Background Color Based on Data Source Field - Kendo UI for jQuery
6+
slug: how-to-set-grid-cell-background-color-kendo-ui
7+
tags: kendo-ui, grid, background-color, jquery, datasource, cell, databound
8+
res_type: kb
9+
ticketid: 1671214
10+
---
11+
12+
## Environment
13+
<table>
14+
<tbody>
15+
<tr>
16+
<td>Product</td>
17+
<td>Kendo UI for jQuery Grid</td>
18+
</tr>
19+
<tr>
20+
<td>Version</td>
21+
<td>2024.4.1112</td>
22+
</tr>
23+
</tbody>
24+
</table>
25+
26+
## Description
27+
28+
Setting the background color of cells in the Kendo UI for jQuery Grid based on a field from the dataSource is a common requirement. This knowledge base article demonstrates how to dynamically apply background colors to the entire cell using the values from the dataSource.
29+
30+
This knowledge base article also answers the following questions:
31+
- How can I apply a background color to the entire Grid cell using dataSource field values?
32+
- How to use a dataSource field value for setting cell background color in Kendo UI for jQuery Grid?
33+
- What is the method to dynamically change Grid cell background based on dataItem in Kendo UI for jQuery?
34+
35+
## Solution
36+
37+
To dynamically set the background color of cells in a Kendo UI for jQuery Grid, utilize a combination of column templates and the `dataBound` event. Define a class in the template element and then, during the `dataBound` event, set the background color of the cell's parent element to match the desired color.
38+
39+
### Setting Background Using Class and Parent Element
40+
41+
1. Define a class in your column template. This class will be used to identify the cells whose background color needs to be changed.
42+
43+
2. Use the `dataBound` event to identify these cells and set the background color of their parent elements.
44+
45+
```javascript
46+
$("#grid").kendoGrid({
47+
dataSource: dataSource,
48+
dataBound: function(e){
49+
$(".colorChange.pink").parent().css("background-color", "pink");
50+
$(".colorChange.green").parent().css("background-color", "green");
51+
$(".colorChange.yellow").parent().css("background-color", "yellow");
52+
},
53+
pageable: true,
54+
toolbar: ["create"],
55+
columns: [
56+
{ field: "ProductName", title: "Product Name" },
57+
{ field: "UnitPrice", title: "Price", format: "{0:c}", width: "120px" },
58+
{
59+
field: "UnitsInStock",
60+
title:"Units In Stock",
61+
width: "120px",
62+
template: "#{# <span style='background-color: #:Color#;' class='colorChange #:Color#'> #:UnitsInStock# </span> #}#"
63+
},
64+
{ command: ["edit", "destroy"], title: "&nbsp;", width: "200px" }
65+
],
66+
editable: "inline"
67+
});
68+
```
69+
70+
To see setting the background using a class and parent element in action, refer to this [Progress Kendo UI Dojo](https://dojo.telerik.com/cIMtPIZe).
71+
72+
### Dynamically Setting Background Based on DataSource Field
73+
74+
To dynamically use a field from the dataSource as the background color:
75+
76+
1. Add a class to your template item without specifying the background color inline.
77+
78+
2. During the `dataBound` event, iterate through the dataSource items, retrieve the color value from the `Color` field, and apply it to the relevant cell.
79+
80+
```javascript
81+
dataBound: function(e){
82+
var dataItems = e.sender.dataSource.view();
83+
for (var j = 0; j < dataItems.length; j++) {
84+
var color = dataItems[j].get("Color");
85+
var row = e.sender.tbody.find("[data-uid='" + dataItems[j].uid + "']");
86+
$(row).find(".colorChange").parent().css("background-color", color);
87+
}
88+
},
89+
```
90+
91+
For a practical demonstration of dynamically setting the background with a dataSource field, refer to this [Progress Kendo UI Dojo](https://dojo.telerik.com/NfFWNtWO).
92+
93+
## See Also
94+
- [Column Template in Kendo UI Grid](https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/configuration/columns.template)
95+
- [DataBound Event in Kendo UI Grid](https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/events/databound)
96+
- [Styling Rows and Cells Based on Data Item Values](https://docs.telerik.com/kendo-ui/knowledge-base/style-rows-cells-based-on-data-item-values)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: Cannot read properties of undefined (reading 'getRandomValues')
3+
page_title: Cannot read properties of undefined (reading 'getRandomValues')
4+
description: "Learn how to resolve the error message about the getRandomValues method."
5+
slug: howto_resolve_getrandomvalues_message
6+
tags: telerik, kendo, jquery, guid, crypto, getRandomValues, grid, error, defined
7+
type: how-to
8+
res_type: kb
9+
---
10+
11+
## Description
12+
13+
I am getting the following error when I try to initialize a component or when I try to call the `kendo.guid()` method. Why?
14+
15+
```
16+
Cannot read properties of undefined (reading 'getRandomValues')
17+
```
18+
19+
## Solution
20+
21+
Newer versions of Kendo UI for jQuery use the [`Crypto`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto) interface to generate cryptographically secure unique ids. This interface is available in the `window` object of all modern browsers.
22+
23+
However, if you are working in an environment such as `jsdom`, it is possible that the `crypto` interface will not be available. In such cases, you can manually require it and assign it to the `window` object before you import the Kendo components.
24+
25+
```javascript
26+
window.crypto = require("crypto");
27+
```
28+
29+
Alternatively, you could create a custom implementation of the `getRandomValues` method:
30+
31+
```javascript
32+
const crypto = {
33+
getRandomValues: () => {
34+
// Custom implementation that returns an array of 16 random integers.
35+
// Using Math.random is not advisable. For more information read the note here:
36+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random
37+
const get16RandomNumbers = myCustomFunctionThatGenerates16RandomIntegers();
38+
return get16RandomNumbers;
39+
}
40+
};
41+
42+
window.crypto = crypto;
43+
```
44+
45+
However, we'd strongly advise against doing that as this could compromise the randomness of the generated numbers.
46+
47+
## See Also
48+
49+
* [getRandomValues Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues)
50+
* [Crypto Interface](https://developer.mozilla.org/en-US/docs/Web/API/Crypto)
51+
* [Crypto Interface in JSDOM Discussion](https://github.com/jsdom/jsdom/issues/1612)

src/kendo.core.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var packageMetadata = {
2525
isArray = Array.isArray,
2626
noop = $.noop,
2727
math = Math,
28+
crypto = window.crypto,
2829
Template,
2930
JSON = window.JSON || {},
3031
support = {},
@@ -3218,20 +3219,20 @@ function pad(number, digits, end) {
32183219
},
32193220

32203221
guid: function() {
3221-
var id = "", i, random, chars = "abcdef";
3222-
3223-
id += chars[Math.floor(Math.random() * Math.floor(chars.length))];
3224-
3225-
for (i = 1; i < 32; i++) {
3226-
random = math.random() * 16 | 0;
3227-
3228-
if (i == 8 || i == 12 || i == 16 || i == 20) {
3229-
id += "-";
3230-
}
3231-
id += (i == 12 ? 4 : (i == 16 ? (random & 3 | 8) : random)).toString(16);
3222+
try {
3223+
// This is available only in HTTPS.
3224+
return crypto.randomUUID();
3225+
} catch (e) {
3226+
// Use this as a fallback.
3227+
const randomValues = crypto.getRandomValues(new Uint8Array(16));
3228+
return randomValues.reduce((acc, curr, i) => {
3229+
if (i === 4 || i === 6 || i === 8 || i === 10) {
3230+
acc += "-";
3231+
}
3232+
acc += curr.toString(16).padStart(2, '0');
3233+
return acc;
3234+
}, "");
32323235
}
3233-
3234-
return id;
32353236
},
32363237

32373238
roleSelector: function(role) {

0 commit comments

Comments
 (0)