Skip to content

Commit 9ab5f64

Browse files
Update Scheduler Server filtering example to send correctly the view start / end time in case the Scheduler is using timezone different than UTC.
1 parent fd5ae9a commit 9ab5f64

File tree

5 files changed

+62
-15
lines changed

5 files changed

+62
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
6+
namespace KendoUI_Scheduler_Server_Filtering.Controllers
7+
{
8+
public class FilterRange
9+
{
10+
private DateTime start;
11+
public DateTime Start
12+
{
13+
get
14+
{
15+
return start;
16+
}
17+
set
18+
{
19+
start = value.ToUniversalTime();
20+
}
21+
}
22+
23+
private DateTime end;
24+
public DateTime End
25+
{
26+
get
27+
{
28+
return end;
29+
}
30+
set
31+
{
32+
end = value.ToUniversalTime();
33+
}
34+
}
35+
36+
37+
}
38+
}

scheduler/scheduler-server-filtering/KendoUI_Scheduler_Server_Filtering/Controllers/HomeController.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ namespace KendoUI_Scheduler_Server_Filtering.Controllers
99
{
1010
public class HomeController : Controller
1111
{
12-
1312
private SchedulerTaskService taskService;
1413

1514
public HomeController()
@@ -22,9 +21,9 @@ public ActionResult Index()
2221
return View();
2322
}
2423

25-
public virtual JsonResult Read(DataSourceRequest request, DateTime start, DateTime end)
24+
public virtual JsonResult Read(DataSourceRequest request, FilterRange range)
2625
{
27-
var data = taskService.GetRange(start, end);
26+
var data = taskService.GetRange(range.Start, range.End);
2827
return Json(data.ToDataSourceResult(request));
2928
}
3029

scheduler/scheduler-server-filtering/KendoUI_Scheduler_Server_Filtering/KendoUI_Scheduler_Server_Filtering.csproj

+5-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<AssemblyName>KendoUI_Scheduler_Server_Filtering</AssemblyName>
1616
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1717
<MvcBuildViews>false</MvcBuildViews>
18-
<UseIISExpress>true</UseIISExpress>
18+
<UseIISExpress>false</UseIISExpress>
1919
<IISExpressSSLPort />
2020
<IISExpressAnonymousAuthentication />
2121
<IISExpressWindowsAuthentication />
@@ -133,6 +133,7 @@
133133
<Compile Include="App_Start\FilterConfig.cs" />
134134
<Compile Include="App_Start\RouteConfig.cs" />
135135
<Compile Include="App_Start\WebApiConfig.cs" />
136+
<Compile Include="Controllers\FilterRange.cs" />
136137
<Compile Include="Controllers\HomeController.cs" />
137138
<Compile Include="Global.asax.cs">
138139
<DependentUpon>Global.asax</DependentUpon>
@@ -263,11 +264,11 @@
263264
<VisualStudio>
264265
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
265266
<WebProjectProperties>
266-
<UseIIS>True</UseIIS>
267+
<UseIIS>False</UseIIS>
267268
<AutoAssignPort>True</AutoAssignPort>
268-
<DevelopmentServerPort>0</DevelopmentServerPort>
269+
<DevelopmentServerPort>46979</DevelopmentServerPort>
269270
<DevelopmentServerVPath>/</DevelopmentServerVPath>
270-
<IISUrl>http://localhost:43849/</IISUrl>
271+
<IISUrl>http://localhost/KendoUI_Scheduler_Server_Filtering</IISUrl>
271272
<NTLMAuthentication>False</NTLMAuthentication>
272273
<UseCustomServer>False</UseCustomServer>
273274
<CustomServerUrl>

scheduler/scheduler-server-filtering/KendoUI_Scheduler_Server_Filtering/Views/Home/Index.cshtml

+11-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,18 @@
3232
function getAdditionalData() {
3333
var scheduler = $("#scheduler").data("kendoScheduler");
3434
35+
var timezone = scheduler.options.timezone;
36+
var startDate = kendo.timezone.convert(scheduler.view().startDate(), timezone, "Etc/UTC");
37+
var endDate = kendo.timezone.convert(scheduler.view().endDate(), timezone, "Etc/UTC");
38+
39+
//optionally add startTime / endTime of the view
40+
var startTime = kendo.date.getMilliseconds(scheduler.view().startTime());
41+
var endTime = kendo.date.getMilliseconds(scheduler.view().endTime());
42+
endTime = endTime == 0 ? kendo.date.MS_PER_DAY : endTime;
43+
3544
var result = {
36-
start: scheduler.view().startDate().toISOString(),
37-
end: scheduler.view().endDate().toISOString()
45+
Start: new Date(startDate.getTime() - (startDate.getTimezoneOffset() * kendo.date.MS_PER_MINUTE) + startTime),
46+
End: new Date(endDate.getTime() - (endDate.getTimezoneOffset() * kendo.date.MS_PER_MINUTE) + endTime)
3847
}
3948
4049
return result;

scheduler/scheduler-server-filtering/KendoUI_Scheduler_Server_Filtering/Views/Shared/_Layout.cshtml

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
@Scripts.Render("~/bundles/modernizr")
99

1010
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
11-
<link href="http://cdn.kendostatic.com/2013.3.1119/styles/kendo.common.min.css" rel="stylesheet" type="text/css" />
12-
<link href="http://cdn.kendostatic.com/2013.3.1119/styles/kendo.default.min.css" rel="stylesheet" type="text/css" />
13-
<script src="http://cdn.kendostatic.com/2013.3.1119/js/jquery.min.js"></script>
14-
<script src="http://cdn.kendostatic.com/2013.3.1119/js/kendo.all.min.js"></script>
15-
<script src="http://cdn.kendostatic.com/2013.3.1119/js/kendo.timezones.min.js"></script>
16-
<script src="http://cdn.kendostatic.com/2013.3.1119/js/kendo.aspnetmvc.min.js"></script>
11+
<link href="http://cdn.kendostatic.com/2015.3.930/styles/kendo.common.min.css" rel="stylesheet" type="text/css" />
12+
<link href="http://cdn.kendostatic.com/2015.3.930/styles/kendo.default.min.css" rel="stylesheet" type="text/css" />
13+
<script src="http://cdn.kendostatic.com/2015.3.930/js/jquery.min.js"></script>
14+
<script src="http://cdn.kendostatic.com/2015.3.930/js/kendo.all.min.js"></script>
15+
<script src="http://cdn.kendostatic.com/2015.3.930/js/kendo.timezones.min.js"></script>
16+
<script src="http://cdn.kendostatic.com/2015.3.930/js/kendo.aspnetmvc.min.js"></script>
1717
<script src="@Url.Content("~/Scripts/kendo.modernizr.custom.js")"></script>
1818
</head>
1919
<body>

0 commit comments

Comments
 (0)