|
9 | 9 |
|
10 | 10 | * With Server-side Blazor, the file may become larger than the default SignalR connection limit, and this can disconnect the client and result in an error. Generally, this requires quite a lot of data to happen, but you may need to increase the size limit of the connection in the `ConfigureServices` method of your `Startup.cs` file, for example: |
11 | 11 |
|
12 | | - **C#** |
13 | | - |
14 | | - services.AddServerSideBlazor().AddHubOptions(o => |
15 | | - { |
16 | | - o.MaximumReceiveMessageSize = 1024 * 1024; // 1MB |
17 | | - }); |
| 12 | +````C#.skip-repl |
| 13 | +services.AddServerSideBlazor().AddHubOptions(o => |
| 14 | +{ |
| 15 | + o.MaximumReceiveMessageSize = 1024 * 1024; // 1MB |
| 16 | +}); |
| 17 | +```` |
18 | 18 |
|
19 | 19 | * With Client-side Blazor (WebAssembly), all the code runs in the browser and, at the time of writing, is considerably slower than server-side Blazor, and it only has one actual thread. This means that while the file is being generated, the UI will be unresponsive, so you may want to show a loading sign to the user through the `OnClick` handler of the command button, something like: |
20 | 20 |
|
21 | | - **Component** |
22 | | - |
23 | | - @* Exporting a lot of rows can be slow in a WebAssembly app more so than in a server-side app, and it blocks the UI *@ |
| 21 | +````RAZOR.skip-repl Component |
| 22 | +@* Exporting a lot of rows can be slow in a WebAssembly app more so than in a server-side app, and it blocks the UI *@ |
24 | 23 | |
25 | | - <TelerikGrid Data="@GridData" AutoGenerateColumns="true" Pageable="true"> |
26 | | - <GridToolBarTemplate> |
27 | | - <GridCommandButton OnClick="@ShowLoadingSign" Command="ExcelExport" Icon="@SvgIcon.FileExcel">Export to Excel</GridCommandButton> |
28 | | - <GridCommandButton OnClick="@ShowLoadingSign" Command="CsvExport" Icon="@SvgIcon.FileCsv">Export to CSV</GridCommandButton> |
29 | | - </GridToolBarTemplate> |
30 | | - <GridExport> |
31 | | - <GridExcelExport AllPages="true" FileName="telerik-grid-export" /> |
32 | | - <GridCsvExport AllPages="true" FileName="telerik-grid-export" /> |
33 | | - </GridExport> |
34 | | - </TelerikGrid> |
| 24 | +<TelerikGrid Data="@GridData" AutoGenerateColumns="true" Pageable="true"> |
| 25 | + <GridToolBarTemplate> |
| 26 | + <GridCommandButton OnClick="@ShowLoadingSign" Command="ExcelExport" Icon="@SvgIcon.FileExcel">Export to Excel</GridCommandButton> |
| 27 | + <GridCommandButton OnClick="@ShowLoadingSign" Command="CsvExport" Icon="@SvgIcon.FileCsv">Export to CSV</GridCommandButton> |
| 28 | + </GridToolBarTemplate> |
| 29 | + <GridExport> |
| 30 | + <GridExcelExport AllPages="true" FileName="telerik-grid-export" /> |
| 31 | + <GridCsvExport AllPages="true" FileName="telerik-grid-export" /> |
| 32 | + </GridExport> |
| 33 | +</TelerikGrid> |
35 | 34 | |
36 | | - <TelerikWindow Visible="@isExporting" Modal="true"> |
37 | | - <WindowTitle>Please wait...</WindowTitle> |
38 | | - <WindowContent>We are exporting your data, your file will download shortly.</WindowContent> |
39 | | - </TelerikWindow> |
| 35 | +<TelerikWindow Visible="@isExporting" Modal="true"> |
| 36 | + <WindowTitle>Please wait...</WindowTitle> |
| 37 | + <WindowContent>We are exporting your data, your file will download shortly.</WindowContent> |
| 38 | +</TelerikWindow> |
40 | 39 | |
41 | | - @code { |
42 | | - bool isExporting { get; set; } |
| 40 | +@code { |
| 41 | + bool isExporting { get; set; } |
43 | 42 | |
44 | | - async Task ShowLoadingSign() |
45 | | - { |
46 | | - isExporting = true; |
47 | | - StateHasChanged(); |
48 | | - // This won't work for server-side Blazor, the UI will render immediately after the delay and the loading sign will only flicker |
49 | | - await Task.Delay(50); |
50 | | - isExporting = false; |
51 | | - } |
| 43 | + async Task ShowLoadingSign() |
| 44 | + { |
| 45 | + isExporting = true; |
| 46 | + StateHasChanged(); |
| 47 | + // This won't work for server-side Blazor, the UI will render immediately after the delay and the loading sign will only flicker |
| 48 | + await Task.Delay(50); |
| 49 | + isExporting = false; |
| 50 | + } |
52 | 51 | |
53 | | - List<SampleData> GridData { get; set; } |
| 52 | + List<SampleData> GridData { get; set; } |
54 | 53 | |
55 | | - protected override void OnInitialized() |
56 | | - { |
57 | | - GridData = Enumerable.Range(1, 1000).Select(x => new SampleData |
58 | | - { |
59 | | - ProductId = x, |
60 | | - ProductName = $"Product {x}", |
61 | | - UnitsInStock = x * 2, |
62 | | - Price = 3.14159m * x, |
63 | | - Discontinued = x % 4 == 0, |
64 | | - FirstReleaseDate = DateTime.Now.AddDays(-x) |
65 | | - }).ToList(); |
66 | | - } |
| 54 | + protected override void OnInitialized() |
| 55 | + { |
| 56 | + GridData = Enumerable.Range(1, 1000).Select(x => new SampleData |
| 57 | + { |
| 58 | + ProductId = x, |
| 59 | + ProductName = $"Product {x}", |
| 60 | + UnitsInStock = x * 2, |
| 61 | + Price = 3.14159m * x, |
| 62 | + Discontinued = x % 4 == 0, |
| 63 | + FirstReleaseDate = DateTime.Now.AddDays(-x) |
| 64 | + }).ToList(); |
| 65 | + } |
67 | 66 | |
68 | | - public class SampleData |
69 | | - { |
70 | | - public int ProductId { get; set; } |
71 | | - public string ProductName { get; set; } |
72 | | - public int UnitsInStock { get; set; } |
73 | | - public decimal Price { get; set; } |
74 | | - public bool Discontinued { get; set; } |
75 | | - public DateTime FirstReleaseDate { get; set; } |
76 | | - } |
77 | | - } |
| 67 | + public class SampleData |
| 68 | + { |
| 69 | + public int ProductId { get; set; } |
| 70 | + public string ProductName { get; set; } |
| 71 | + public int UnitsInStock { get; set; } |
| 72 | + public decimal Price { get; set; } |
| 73 | + public bool Discontinued { get; set; } |
| 74 | + public DateTime FirstReleaseDate { get; set; } |
| 75 | + } |
| 76 | +} |
| 77 | +```` |
78 | 78 | #end |
0 commit comments