Skip to content

Commit 9e53306

Browse files
author
Kendo Bot
committed
Sync with Kendo UI Professional
1 parent 1be6b42 commit 9e53306

File tree

15 files changed

+290
-22
lines changed

15 files changed

+290
-22
lines changed

docs-aspnet/html-helpers/data-management/treelist/accessibility/keyboard-navigation.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@ To return the focus on the table cell, press `Esc`. In order for the hyperlinks
3232

3333
You can also avoid the procedure and bypass the keyboard navigation of the TreeList, access the custom hyperlinks with tabbing, and activate them with `Enter`. To achieve this, prevent the `keydown` event bubbling of the custom hyperlinks. As a result, the `Enter` key-presses will be unnoticed by the TreeList.
3434

35+
## Pager Navigation
36+
37+
The Pager wrapper can be focused via the `Tab` key. In case of multiple focusable button elements(such as Edit and Delete buttons), pressing `Tab` will bring the focus to them. In such cases it is recommended that the Developer chooses a custom key/key combination which focuses the Pager wrapper.
38+
39+
$(document.body).keydown(function (e) {
40+
// ALT KEY + S will focus the pager wrapper
41+
if (e.altKey && e.keyCode == 83) {
42+
$("#treelist .k-pager-wrap").focus();
43+
}
44+
});
45+
46+
The TreeList's pager inherits all of the keyboard navigation functionalities from the [{{ site.framework }} Pager](https://docs.telerik.com/{{ site.platform }}/html-helpers/data-management/pager/overview).
47+
48+
For a complete list of all supported key combinations, refer to the [Pager's Keyboard Navigation](https://docs.telerik.com/{{ site.platform }}/html-helpers/data-management/pager/accessibility/keyboard-navigation) article.
49+
3550
## See Also
3651

3752
* [Keyboard Navigation by the TreeList HtmlHelper for {{ site.framework }} (Demo)](https://demos.telerik.com/{{ site.platform }}/treelist/keyboard-navigation)
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
---
2+
title: Hide Grid Columns When the Browser Width Is Too Small
3+
description: "An example demonstrating how to hide the Grid columns in the detail template when the width of the browser is too small."
4+
type: how-to
5+
page_title: Collapse Other Rows on Row Expand | Kendo UI Grid for jQuery
6+
slug: grid-browser-resize-hides-columns-in-detail-template
7+
tags: grid, hierarchy, collapse, expand, hide, columns, column, detail, template
8+
ticketid: 1358601
9+
res_type: kb
10+
---
11+
12+
## Environment
13+
14+
<table>
15+
<tr>
16+
<td>Product</td>
17+
<td>Progress Kendo UI Grid</td>
18+
</tr>
19+
<tr>
20+
<td>Progress Kendo UI version</td>
21+
<td>Created with the 2021.3.914 version</td>
22+
</tr>
23+
</table>
24+
25+
## Description
26+
27+
How can I hide the Grid columns inside the [`detailTemplate`](/api/javascript/ui/grid/configuration/detailtemplate) when the width of the browser window becomes too small?
28+
29+
## Solution
30+
31+
1. Define the thresholds at which each individual column will be hidden. Refer to the `getThresholds` function in the example below.
32+
1. Set these thresholds to the Grid by using the [`columns.media`](/api/javascript/ui/grid/configuration/columns.media) configuration. Refer to the `setThresholds` function in the example below.
33+
1. Attach handlers for the [`dataBound`](/api/javascript/ui/grid/events/databound), [`columnHide`](/api/javascript/ui/grid/events/columnhide), and [`columnShow`](/api/javascript/ui/grid/events/columnshow) events to the Grid. The `columnHide` and `columnShow` handlers are responsible for hiding and showing the columns inside the `detailTemplate`. The `dataBound` handler is responsible for initializing the `detailTemplate`.
34+
1. Handle the `resize` event of the JavaScript `window` object. If the Grid doesn't have any hidden columns when the browser window is resized, collapse all detail rows.
35+
1. Use `CSS` to conditionally display the hierarchy column.
36+
37+
The following example demonstrates the full implementation of the suggested approach. It is recommended that you run the demo in fullscreen&mdash;copy the code and paste it in a new [`dojo`](https://dojo.telerik.com/); then, click **Full screen**.
38+
39+
```dojo
40+
<div id="grid"></div>
41+
42+
<script type="text/x-kendo-template" id="template">
43+
<div class="detail-columns-wrapper">
44+
<span class="hidden" data-field="Title">Title - #=data.Title#</span></br>
45+
<span class="hidden" data-field="City">City - #=data.City#</span></br>
46+
<span class="hidden" data-field="Country">Country - #=data.Country#</span></br>
47+
<span class="hidden" data-field="LastName">Last Name - #=data.LastName#</span></br>
48+
<span class="hidden" data-field="FirstName">First Name - #=data.FirstName#</span>
49+
</div>
50+
</script>
51+
52+
<script>
53+
// The initialWidth is used to calculate the thresholds at which each column will be hidden.
54+
let initialWidth = 1000;
55+
56+
$(document).ready(function () {
57+
var grid = $("#grid").kendoGrid({
58+
dataSource: {
59+
type: "odata",
60+
transport: {
61+
read: "https://demos.telerik.com/kendo-ui/service/Northwind.svc/Employees"
62+
},
63+
pageSize: 20,
64+
serverPaging: true,
65+
serverSorting: true
66+
},
67+
height: 550,
68+
sortable: true,
69+
pageable: false,
70+
dataBound: dataBoundHandler,
71+
detailTemplate: kendo.template($("#template").html()),
72+
columnHide: columnHideHandler,
73+
columnShow: columnShowHandler,
74+
columns: [
75+
{
76+
field: "FirstName",
77+
title: "First Name",
78+
width: 120
79+
},
80+
{
81+
field: "LastName",
82+
title: "Last Name",
83+
width: 120
84+
},
85+
{
86+
field: "Country",
87+
width: 120
88+
},
89+
{
90+
field: "City",
91+
width: 120
92+
},
93+
{
94+
field: "Title",
95+
width: 220
96+
}
97+
]
98+
}).data("kendoGrid");
99+
100+
let columns = grid.options.columns;
101+
let columnsCount = columns.length;
102+
103+
let thresholds = getThresholds(columns, columnsCount, grid, initialWidth);
104+
setThresholds(columns, columnsCount, grid, thresholds);
105+
106+
/* Collapse the rows if there are no hidden columns. */
107+
$(window).on("resize", function () {
108+
let windowWidth = $(this).width();
109+
110+
if (windowWidth > 780) {
111+
$(".k-master-row").each(function () {
112+
grid.collapseRow(this);
113+
});
114+
}
115+
});
116+
117+
});
118+
119+
function columnHideHandler(e) {
120+
$(".detail-columns-wrapper").find("[data-field='" + e.column.field + "']").removeClass("hidden");
121+
}
122+
123+
function columnShowHandler(e) {
124+
$(".detail-columns-wrapper").find("[data-field='" + e.column.field + "']").addClass("hidden");
125+
}
126+
127+
function dataBoundHandler(e) {
128+
let grid = this;
129+
// Initialize all of the detail templates.
130+
$(".k-master-row").each(function () {
131+
grid.expandRow(this);
132+
grid.collapseRow(this)
133+
});
134+
135+
// If the Grid is already shrunken when the page loads, find the hidden columns.
136+
let hiddenColumns = grid.columns.filter(f => f.matchesMedia == false);
137+
138+
// Remove the "hidden" class from the span elements that have their column counterparts hidden.
139+
hiddenColumns.forEach(function (x, i) {
140+
$(".k-detail-row").find("[data-field='" + x.field + "']").removeClass("hidden");
141+
});
142+
}
143+
144+
function setThresholds(columns, count, grid, thresholds) {
145+
// Start from 1 so the first column is always visible.
146+
for (let i = 1; i < count; i++) {
147+
columns[i].media = "(min-width: " + thresholds[i] + "px)";
148+
}
149+
150+
grid.setOptions({
151+
columns: columns
152+
});
153+
}
154+
155+
function getThresholds(columns, count, grid, initialWidth) {
156+
let thresholds = [];
157+
let acc = 0;
158+
159+
// Get the thresholds at which the columns will be hidden. Modify the calculations in any way you see fit.
160+
// In this case the thresholds are calculated with the following formula:
161+
// initialWidth - (width of the last visible column) - (combined width of all already hidden columns.)
162+
for (let i = 0; i < count; i++) {
163+
let threshold = initialWidth - (columns[count - 1 - i].width) - acc;
164+
acc += (columns[count - 1 - i].width);
165+
166+
thresholds.push(threshold);
167+
}
168+
169+
thresholds.reverse();
170+
171+
return thresholds;
172+
}
173+
</script>
174+
175+
<style>
176+
/* Used to remove the empty space when a column is removed. */
177+
#grid table {
178+
min-width: 100%;
179+
}
180+
181+
.hidden {
182+
display: none;
183+
}
184+
185+
/* Hide the hierarchy column. */
186+
colgroup col:nth-child(1) {
187+
width: 0px !important;
188+
}
189+
190+
.k-i-expand {
191+
display: none !important;
192+
}
193+
194+
/* Display the hierarchy column when the width of the browser window becomes less than 780px. */
195+
/* 780px is the initialWidth(1000px) - the width of the last column(220px) */
196+
@media (max-width: 780px) {
197+
colgroup col:nth-child(1) {
198+
width: 32px !important;
199+
}
200+
201+
.k-i-expand {
202+
display: block !important;
203+
}
204+
}
205+
</style>
206+
```

src/messages/kendo.messages.bg-BG.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,9 @@ $.extend(true, kendo.ui.MediaPlayer.prototype.options.messages,{
380380
"mute": "Заглушаване на звука",
381381
"unmute": "Включване на звука",
382382
"quality": "Промяна на качеството",
383-
"fullscreen": "Цял екран"
383+
"fullscreen": "Цял екран",
384+
"volume": "сила на звука",
385+
"time": "време"
384386
});
385387
}
386388

src/messages/kendo.messages.en-AU.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,4 +1394,20 @@ if (kendo.dataviz.ui.Map) {
13941394
});
13951395
}
13961396

1397+
/* MediaPlayer messages */
1398+
1399+
if (kendo.ui.MediaPlayer) {
1400+
kendo.ui.MediaPlayer.prototype.options.messages =
1401+
$.extend(true, kendo.ui.MediaPlayer.prototype.options.messages,{
1402+
"pause": "Pause",
1403+
"play": "Play",
1404+
"mute": "Mute",
1405+
"unmute": "Unmute",
1406+
"quality": "Quality",
1407+
"fullscreen": "Full Screen",
1408+
"volume": "volume",
1409+
"time": "time"
1410+
});
1411+
}
1412+
13971413
})(window.kendo.jQuery);

src/messages/kendo.messages.en-CA.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,4 +1408,20 @@ if (kendo.dataviz.ui.Map) {
14081408
});
14091409
}
14101410

1411+
/* MediaPlayer messages */
1412+
1413+
if (kendo.ui.MediaPlayer) {
1414+
kendo.ui.MediaPlayer.prototype.options.messages =
1415+
$.extend(true, kendo.ui.MediaPlayer.prototype.options.messages,{
1416+
"pause": "Pause",
1417+
"play": "Play",
1418+
"mute": "Mute",
1419+
"unmute": "Unmute",
1420+
"quality": "Quality",
1421+
"fullscreen": "Full Screen",
1422+
"volume": "volume",
1423+
"time": "time"
1424+
});
1425+
}
1426+
14111427
})(window.kendo.jQuery);

src/messages/kendo.messages.en-GB.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -538,15 +538,17 @@ $.extend(true, kendo.ui.NumericTextBox.prototype.options,{
538538
/* MediaPlayer messages */
539539

540540
if (kendo.ui.MediaPlayer) {
541-
kendo.ui.MediaPlayer.prototype.options.messages =
542-
$.extend(true, kendo.ui.MediaPlayer.prototype.options.messages,{
543-
"pause": "Pause",
544-
"play": "Play",
545-
"mute": "Mute",
546-
"unmute": "Unmute",
547-
"quality": "Quality",
548-
"fullscreen": "Full Screen"
549-
});
541+
kendo.ui.MediaPlayer.prototype.options.messages =
542+
$.extend(true, kendo.ui.MediaPlayer.prototype.options.messages,{
543+
"pause": "Pause",
544+
"play": "Play",
545+
"mute": "Mute",
546+
"unmute": "Unmute",
547+
"quality": "Quality",
548+
"fullscreen": "Full Screen",
549+
"volume": "volume",
550+
"time": "time"
551+
});
550552
}
551553

552554
/* Pager messages */

src/messages/kendo.messages.en-US.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,9 @@ $.extend(true, kendo.ui.MediaPlayer.prototype.options.messages,{
596596
"mute": "Mute",
597597
"unmute": "Unmute",
598598
"quality": "Quality",
599-
"fullscreen": "Full Screen"
599+
"fullscreen": "Full Screen",
600+
"volume": "volume",
601+
"time": "time"
600602
});
601603
}
602604

styles/web/Default/colorpicker/_layout.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@
321321
position: relative;
322322
display: inline-block;
323323
vertical-align: middle;
324+
line-height: @colorpicker-line-height;
324325
overflow: visible;
325326
width: auto;
326327
outline: 0;

styles/web/common/editor.less

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ table.k-editor {
8585

8686
// Group
8787
.k-tool-group {
88-
.k-widget ~ .k-widget {
88+
.k-widget ~ .k-widget,
89+
.k-colorpicker ~ .k-colorpicker {
8990
margin-inline-start: @toolbar-spacing;
9091
}
9192
}

styles/web/kendo.common-bootstrap.less

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,16 +1280,7 @@
12801280

12811281

12821282
// ColorPicker
1283-
// @colorpicker-font-family: inherit;
1284-
// @colorpicker-font-size: inherit;
1285-
// @colorpicker-line-height: @line-height;
1286-
1287-
// @colorpicker-select-border-width: 1px;
1288-
1289-
// @colorpicker-bg: @button-bg;
1290-
// @colorpicker-text: @button-text;
1291-
// @colorpicker-border: @button-border;
1292-
// @colorpicker-gradient: @button-gradient;
1283+
@colorpicker-line-height: 2.29285714em;
12931284

12941285

12951286
@import "common/all.less";

0 commit comments

Comments
 (0)