Skip to content

Commit 5059435

Browse files
author
Kendo Bot
committed
Sync with Kendo UI Professional
1 parent 7139a99 commit 5059435

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: Cancellation Token
3+
page_title: Passing a Cancellation Token
4+
description: "Learn how to cancel an asynchronous call by passing additional parameter to the DataSource method."
5+
slug: htmlhelper_datasource_cancellationtoken
6+
---
7+
8+
# Description
9+
10+
It is possible to cancel the asynchronous call to database query or some other action if the time limit is reached or due to another problem. This is achieved by passing a [CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken?view=netframework-4.8) parameter to the [ToDataSourceResultAsync](https://docs.telerik.com/{{ site.platform }}/knowledge-base/grid-add-asynchronous-calls-to-action-methods) method of the DataSource instance.
11+
12+
In real-case scenarios, developers usually have also to consider other factors like Connection Time Limit, Invalid Input, etc. To help with this task, we exposed the capability to also pass a **CancellationToken** parameter which comes handy in this type of scenarios.
13+
14+
# Example
15+
16+
public async Task<ActionResult> EditingInline_Read([DataSourceRequest] DataSourceRequest request)
17+
{
18+
CancellationTokenSource source = new CancellationTokenSource(2000);
19+
CancellationToken token = source.Token;
20+
21+
var result = await GetOrders().ToDataSourceResultAsync(request, token);
22+
return Json(result);
23+
}
24+
25+
private List<OrderViewModel> GetOrders()
26+
{
27+
Thread.Sleep(3000);
28+
return Enumerable.Range(0, 50).Select(i => new OrderViewModel
29+
{
30+
OrderID = i,
31+
Freight = i * 10,
32+
OrderDate = DateTime.Now.AddDays(i),
33+
ShipName = "ShipName " + i,
34+
ShipCity = "ShipCity " + i
35+
}).ToList();
36+
}
37+
38+
39+
You can find a full runnable sample with a Grid integration here:
40+
41+
{% if site.mvc %}
42+
[Grid Sample with Cancellation Token](https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/grid/grid-cancellationtoken/KendoGridCancellationToken)
43+
{% endif %}
44+
45+
{% if site.core %}
46+
[Grid Sample with Cancellation Token](https://github.com/telerik/ui-for-aspnet-core-examples/blob/master/Telerik.Examples.Mvc/Telerik.Examples.Mvc/Views/Grid/AsynchronousBindingWithCancellationToken.cshtml)
47+
{% endif %}
48+

src/kendo.draganddrop.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,10 +894,14 @@ var __meta__ = { // jshint ignore:line
894894

895895
if (yInBounds) {
896896
parent.scrollTop += velocity.y;
897+
} else if (yIsScrollable && yDelta < 0) {
898+
parent.scrollTop = 0;
897899
}
898900

899901
if (xInBounds) {
900902
parent.scrollLeft += velocity.x;
903+
} else if (xIsScrollable && xDelta < 0) {
904+
parent.scrollLeft = 0;
901905
}
902906

903907
if (this.hint && isRootNode && (xInBounds || yInBounds)) {

styles/web/common/base.less

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
.k-slider,
114114
.k-splitter,
115115
.k-treeview,
116+
.k-treeview > .k-group,
116117
.k-panelbar,
117118
.k-content,
118119
.k-header-column-menu {
@@ -125,6 +126,7 @@
125126
.k-splitbar,
126127
.k-calendar,
127128
.k-treeview,
129+
.k-treeview > .k-group,
128130
.k-pager-wrap,
129131
.k-grid-header .k-i-link-horizontal,
130132
.k-header-column-menu {

0 commit comments

Comments
 (0)