Skip to content

Commit be5865d

Browse files
dimodiDimo Dimovmarin-bratanov
authored
Migrate Grid OData examples to v3.0 (#155)
* Migrate Grid OData examples to v3.0 * chore(grid): revert to 3.1 wasm server ref Co-authored-by: Dimo Dimov <dimo@Dimos-MacBook-Pro.local> Co-authored-by: Marin Bratanov <m.bratanov@gmail.com>
1 parent c3c3ac1 commit be5865d

File tree

7 files changed

+21
-31
lines changed

7 files changed

+21
-31
lines changed

grid/odata/ServerApp/Pages/Index.razor

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
@inject ODataOrdersService OrdersService
44
@using ServerApp.Data
55

6-
<TelerikGrid Data=@GridDataOrders
6+
<TelerikGrid TItem="@ODataOrder"
7+
OnRead="@ReadOrders"
78
Height="460px"
89
RowHeight="60"
910
PageSize="10"
1011
Pageable="true"
1112
Sortable="true"
12-
FilterMode="@GridFilterMode.FilterRow"
13-
OnRead=@ReadOrders
14-
TotalCount=@TotalOrders>
13+
FilterMode="@GridFilterMode.FilterRow">
1514
<GridColumns>
1615
<GridColumn Field="OrderID" />
1716
<GridColumn Field="ShipName" />
@@ -20,15 +19,11 @@
2019
</TelerikGrid>
2120

2221
@code{
23-
public List<ODataOrder> GridDataOrders { get; set; } = new List<ODataOrder>();
24-
25-
public int TotalOrders { get; set; } = 0;
26-
2722
protected async Task ReadOrders(GridReadEventArgs args)
2823
{
2924
ODataOrdersResponse data = await OrdersService.GetOrders(args.Request);
3025

31-
GridDataOrders = data.Orders;
32-
TotalOrders = data.Total;
26+
args.Data = data.Orders;
27+
args.Total = data.Total;
3328
}
34-
}
29+
}

grid/odata/ServerApp/Pages/_Host.cshtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
<base href="~/" />
1212
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
1313
<link href="css/site.css" rel="stylesheet" />
14-
<link rel="stylesheet" href="https://unpkg.com/@@progress/kendo-theme-default@@latest/dist/all.css" />
15-
<script src="_content/telerik.ui.for.blazor/js/telerik-blazor.js" defer></script>
14+
15+
<link rel="stylesheet" href="_content/Telerik.UI.for.Blazor/css/kendo-theme-default/all.css" />
16+
<script src="_content/Telerik.UI.for.Blazor/js/telerik-blazor.js" defer></script>
1617
</head>
1718
<body>
1819
<app>@(await Html.RenderComponentAsync<App>(RenderMode.ServerPrerendered))</app>

grid/odata/ServerApp/ServerApp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Telerik.UI.for.Blazor" Version="2.20.0" />
9+
<PackageReference Include="Telerik.UI.for.Blazor" Version="3.0.1" />
1010
</ItemGroup>
1111

1212
</Project>

grid/odata/WasmApp/Client/Pages/Index.razor

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55
@using WasmApp.Shared
66
@inject HttpClient Http
77

8-
<TelerikGrid Data=@GridData
8+
<TelerikGrid TItem="@ODataProduct"
9+
OnRead="@ReadItems"
910
Height="460px"
1011
RowHeight="60"
1112
PageSize="10"
1213
Pageable="true"
1314
Sortable="true"
14-
FilterMode="@GridFilterMode.FilterRow"
15-
OnRead=@ReadItems
16-
TotalCount=@Total>
15+
FilterMode="@GridFilterMode.FilterRow">
1716
<GridColumns>
1817
<GridColumn Field="ProductID" />
1918
<GridColumn Field="ProductName" />
@@ -22,18 +21,15 @@
2221
</TelerikGrid>
2322

2423
@code{
25-
public List<ODataProduct> GridData { get; set; } = new List<ODataProduct>();
26-
public int Total { get; set; } = 0;
27-
28-
protected async Task ReadItems(GridReadEventArgs args)
24+
async Task ReadItems(GridReadEventArgs args)
2925
{
3026
var baseUrl = "https://demos.telerik.com/kendo-ui/service-v4/odata/Products?";
3127

3228
var requestUrl = $"{baseUrl}{args.Request.ToODataString()}";
3329

3430
ODataResponseOrders response = await Http.GetFromJsonAsync<ODataResponseOrders>(requestUrl);
3531

36-
GridData = response.Products;
37-
Total = response.Total;
32+
args.Data = response.Products;
33+
args.Total = response.Total;
3834
}
39-
}
35+
}

grid/odata/WasmApp/Client/WasmApp.Client.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.1" PrivateAssets="all" />
1111
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.1" PrivateAssets="all" />
1212
<PackageReference Include="System.Net.Http.Json" Version="3.2.1" />
13-
<PackageReference Include="Telerik.UI.for.Blazor" Version="2.20.0" />
13+
<PackageReference Include="Telerik.UI.for.Blazor" Version="3.0.1" />
1414
</ItemGroup>
1515
<ItemGroup>
1616
<ProjectReference Include="..\Shared\WasmApp.Shared.csproj" />

grid/odata/WasmApp/Client/wwwroot/index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
<base href="/" />
88
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
99
<link href="css/site.css" rel="stylesheet" />
10-
<link rel="stylesheet" href="https://unpkg.com/@progress/kendo-theme-default@latest/dist/all.css" />
11-
<script src="_content/telerik.ui.for.blazor/js/telerik-blazor.js" defer></script>
10+
11+
<link rel="stylesheet" href="_content/Telerik.UI.for.Blazor/css/kendo-theme-default/all.css" />
12+
<script src="_content/Telerik.UI.for.Blazor/js/telerik-blazor.js" defer></script>
1213
</head>
1314
<body>
1415
<app>Loading...</app>

grid/odata/WasmApp/Server/Startup.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using Microsoft.AspNetCore.ResponseCompression;
44
using Microsoft.Extensions.DependencyInjection;
55
using Microsoft.Extensions.Hosting;
6-
using Newtonsoft.Json.Serialization;
76
using System.Linq;
87

98
namespace WasmApp.Server
@@ -24,7 +23,6 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
2423
if (env.IsDevelopment())
2524
{
2625
app.UseDeveloperExceptionPage();
27-
app.UseWebAssemblyDebugging();
2826
}
2927
else
3028
{
@@ -34,7 +32,6 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
3432
}
3533

3634
app.UseHttpsRedirection();
37-
app.UseBlazorFrameworkFiles();
3835
app.UseStaticFiles();
3936

4037
app.UseRouting();

0 commit comments

Comments
 (0)