Skip to content

Commit e3aa140

Browse files
dimodiDimo Dimovmarin-bratanov
authored
Migrate Grid Dapper example to v3.0 (#162)
* Migrate Grid Dapper example to v3.0 * docs(grid): link dapper sample attribution * chore(grid): remove unnecessary dapper gitignore file Co-authored-by: Dimo Dimov <dimo@Dimos-MacBook-Pro.local> Co-authored-by: Marin Bratanov <m.bratanov@gmail.com>
1 parent 28a58a2 commit e3aa140

File tree

5 files changed

+10
-230
lines changed

5 files changed

+10
-230
lines changed

grid/dapper/.gitignore

Lines changed: 0 additions & 217 deletions
This file was deleted.

grid/dapper/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Demonstrates a Telerik Grid in Blazor, using the OnRead event along with Dapper and Dapper.SqlBuilder, to generate your SQL queries on the fly supporting most aspects of Telerik Grid.
44
Telerik Grid works nicely with Entity Framework, you can use `.ToDataSourceResultAsync()` and everything for sorting etc happens on the database. If you are using Dapper you can use that, however as Dapper doesn't return an IQueryable, you will be fetching the entire dataset and then filtering, paging and sorting in code, rather than on your database.
55

6-
**Special thanks to @pingu2k4 for the sample.**
6+
**Special thanks to [@pingu2k4](https://github.com/pingu2k4) for the sample.**
77

88
## Features
99
- [x] Paging

grid/dapper/dapper/TelerikBlazorGrid-Dapper.Blazor/Pages/Products.razor

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@
33

44
<h3>Products</h3>
55

6-
<TelerikGrid Data="ProductList"
6+
<TelerikGrid TItem="@Product"
77
Class="overflow-auto mb-4"
8-
OnRead="ReadItems"
9-
TotalCount="ProductCount"
8+
OnRead="@ReadItems"
109
Pageable="true"
1110
Sortable="true"
1211
FilterMode="GridFilterMode.FilterMenu"
1312
Resizable="true"
1413
Reorderable="true"
1514
Height="600px"
1615
@bind-PageSize="PageSize"
17-
@ref="Grid">
16+
@ref="@Grid">
1817
<GridToolBar>
1918
<GridCommandButton Icon="arrow-rotate-cw" OnClick="RefreshTable">Refresh</GridCommandButton>
2019
<GridCommandButton Command="ExcelExport" Icon="file-excel">Export .xlsx</GridCommandButton>
@@ -41,20 +40,18 @@
4140

4241
@code {
4342
private TelerikGrid<Product> Grid { get; set; }
44-
private List<Product> ProductList { get; set; }
45-
private int ProductCount { get; set; }
4643
private int PageSize { get; set; } = 10;
4744
private List<int?> PageSizes = new List<int?> { 5, 10, 25, 50, null };
4845

4946
private async Task ReadItems(GridReadEventArgs args)
5047
{
5148
var result = await _productDataService.GetProducts(args.Request);
52-
ProductList = result.Results;
53-
ProductCount = result.Count;
49+
args.Data = result.Results;
50+
args.Total = result.Count;
5451
}
5552

5653
private async Task RefreshTable()
5754
{
58-
await Grid.SetState(Grid.GetState());
55+
Grid.Rebind();
5956
}
6057
}

grid/dapper/dapper/TelerikBlazorGrid-Dapper.Blazor/TelerikBlazorGrid-Dapper.Blazor.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Telerik.DataSource" Version="2.0.11" />
12-
<PackageReference Include="Telerik.UI.for.Blazor" Version="2.27.0" />
11+
<PackageReference Include="Telerik.DataSource" Version="2.1.1" />
12+
<PackageReference Include="Telerik.UI.for.Blazor" Version="3.0.1" />
1313
</ItemGroup>
1414

1515
<ItemGroup>

grid/dapper/dapper/TelerikBlazorGrid-Dapper.DataAccess/TelerikBlazorGrid-Dapper.DataAccess.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<PackageReference Include="Dapper" Version="2.0.90" />
1212
<PackageReference Include="Dapper.SqlBuilder" Version="2.0.78" />
1313
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
14-
<PackageReference Include="Telerik.DataSource" Version="2.0.11" />
14+
<PackageReference Include="Telerik.DataSource" Version="2.1.1" />
1515
</ItemGroup>
1616

1717
</Project>

0 commit comments

Comments
 (0)