Skip to content

Commit c95456b

Browse files
ntachevaikoevskadimodi
authored
chore(grid): refactor export notes (#2835)
* chore(grid): refactor export notes * chore(Grid): add kb for showing loader during export * chore(grid): kb for load cyrillic fonts when exporting to pdf * chore(grid): add example for loading cyrillic fonts * chore(grid): updates * Update components/grid/export/excel.md Co-authored-by: Iva Stefanova Koevska-Atanasova <koevska@progress.com> * Update knowledge-base/grid-load-cyrillic-fonts-in-pdf-export.md Co-authored-by: Iva Stefanova Koevska-Atanasova <koevska@progress.com> * Update knowledge-base/grid-show-loader-while-exporting.md Co-authored-by: Iva Stefanova Koevska-Atanasova <koevska@progress.com> * Update knowledge-base/grid-show-loader-while-exporting.md Co-authored-by: Iva Stefanova Koevska-Atanasova <koevska@progress.com> * Update components/grid/export/excel.md Co-authored-by: Iva Stefanova Koevska-Atanasova <koevska@progress.com> * Update components/grid/export/overview.md Co-authored-by: Iva Stefanova Koevska-Atanasova <koevska@progress.com> * Update components/grid/export/overview.md Co-authored-by: Iva Stefanova Koevska-Atanasova <koevska@progress.com> * Update components/grid/export/overview.md Co-authored-by: Iva Stefanova Koevska-Atanasova <koevska@progress.com> * Update knowledge-base/grid-load-cyrillic-fonts-in-pdf-export.md Co-authored-by: Iva Stefanova Koevska-Atanasova <koevska@progress.com> * Update components/grid/export/pdf.md Co-authored-by: Iva Stefanova Koevska-Atanasova <koevska@progress.com> * Update knowledge-base/grid-load-cyrillic-fonts-in-pdf-export.md Co-authored-by: Iva Stefanova Koevska-Atanasova <koevska@progress.com> * chore(grid): address feedback * Update components/grid/export/overview.md Co-authored-by: Dimo Dimov <961014+dimodi@users.noreply.github.com> * Update components/grid/export/overview.md Co-authored-by: Dimo Dimov <961014+dimodi@users.noreply.github.com> * Update components/grid/export/overview.md Co-authored-by: Dimo Dimov <961014+dimodi@users.noreply.github.com> * Update components/grid/export/overview.md Co-authored-by: Dimo Dimov <961014+dimodi@users.noreply.github.com> * Update components/grid/export/overview.md Co-authored-by: Dimo Dimov <961014+dimodi@users.noreply.github.com> * Update components/grid/export/overview.md Co-authored-by: Dimo Dimov <961014+dimodi@users.noreply.github.com> * Update components/grid/export/pdf.md Co-authored-by: Dimo Dimov <961014+dimodi@users.noreply.github.com> * Update components/grid/export/overview.md Co-authored-by: Dimo Dimov <961014+dimodi@users.noreply.github.com> * chore(grid): address feedback * chore(grid): final updates * chore(grid): update note --------- Co-authored-by: Iva Stefanova Koevska-Atanasova <koevska@progress.com> Co-authored-by: Dimo Dimov <961014+dimodi@users.noreply.github.com>
1 parent 4bd595a commit c95456b

File tree

8 files changed

+506
-199
lines changed

8 files changed

+506
-199
lines changed

Diff for: _contentTemplates/grid/export.md

-78
This file was deleted.

Diff for: components/grid/export/csv.md

+50-41
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Export to CSV the Grid for Blazor.
55
slug: grid-export-csv
66
tags: telerik,blazor,grid,export,csv
77
published: True
8-
position: 1
8+
position: 3
99
---
1010

1111
# Grid CSV Export
@@ -14,25 +14,38 @@ You can export the grid to CSV with a click of a button. The current filter, sor
1414

1515
When you click the Export button, your browser will receive the resulting file.
1616

17+
>tip Make sure to get familiar with all the [general export documentation first](slug:grid-export-overview).
18+
1719
#### In This Article
1820

1921
- [Basics](#basics)
2022
- [Programmatic Export](#programmatic-export)
2123
- [Customization](#customization)
22-
- [Notes](#notes)
23-
- [See Also](#see-also)
2424

2525
## Basics
2626

27-
To enable the grid CSV Export, add a [command button](slug:components/grid/columns/command) with the `CsvExport` command name to the [Grid toolbar](slug:components/grid/features/toolbar).
27+
To enable the CSV export in the Grid:
28+
29+
1. [Add the Export Tool](#add-the-export-tool)
30+
1. [Configure the Export Settings](#configure-the-export-settings)
31+
32+
### Add the Export Tool
33+
34+
Add the `GridToolBarCsvExportTool` inside the [`<GridToolBar>`](slug:components/grid/features/toolbar#command-tools):
2835

2936
````RAZOR.skip-repl
30-
<GridToolBarTemplate>
31-
<GridCommandButton Command="CsvExport" Icon="@SvgIcon.FileCsv">Export to CSV</GridCommandButton>
32-
</GridToolBarTemplate>
37+
<GridToolBar>
38+
<GridToolBarCsvExportTool>
39+
Export to CSV
40+
</GridToolBarCsvExportTool>
41+
</GridToolBar>
3342
````
3443

35-
Optionally, you can also set the `GridCsvExport` tag settings under the `GridExport` tag to subscribe to the [Grid export events](slug:grid-export-events) that allow further customization of the exported columns/data or configure the CSV export options:
44+
If you have a custom Toolbar, add a command button with the `CsvExport` command name inside a [templated Grid Toolbar](slug:components/grid/features/toolbar#custom-toolbar-configuration)(`<GridToolBarTemplate>`).
45+
46+
### Configure the Export Settings
47+
48+
To configure the CSV export settings, add the `GridCsvExport` tag under the `GridExport` tag. You may set the following options:
3649

3750
@[template](/_contentTemplates/common/parameters-table-styles.md#table-layout)
3851

@@ -41,22 +54,29 @@ Optionally, you can also set the `GridCsvExport` tag settings under the `GridExp
4154
| `FileName` | `string` | The name of the file. The grid will add the `.csv` extension for you. |
4255
| `AllPages` | `bool` | Whether to export the current page only, or the entire data from the data source. |
4356

44-
>caption Export the Grid to CSV - Example
57+
For further customizations, use the `GridExcelExport` tag to subscribe to the [Grid export events](slug:grid-export-events).
58+
59+
>caption Export the Grid to CSV
4560
4661
````RAZOR
4762
@* You can sort, group, filter, page the grid, reorder its columns, and you can click the
4863
Export button to save the current data *@
4964
50-
<TelerikGrid Data="@GridData" Pageable="true" Sortable="true" Reorderable="true"
51-
FilterMode="@GridFilterMode.FilterRow" Groupable="true">
65+
<TelerikGrid Data="@GridData"
66+
Pageable="true"
67+
Sortable="true"
68+
Reorderable="true"
69+
FilterMode="@GridFilterMode.FilterRow"
70+
Groupable="true">
5271
53-
<GridToolBarTemplate>
54-
<GridCommandButton Command="CsvExport" Icon="@SvgIcon.FileCsv">Export to CSV</GridCommandButton>
55-
<label class="k-checkbox-label"><TelerikCheckBox @bind-Value="@ExportAllPages" />Export All Pages</label>
56-
</GridToolBarTemplate>
72+
<GridToolBar>
73+
<GridToolBarCsvExportTool>
74+
Export to CSV
75+
</GridToolBarCsvExportTool>
76+
</GridToolBar>
5777
5878
<GridExport>
59-
<GridCsvExport FileName="telerik-grid-export" AllPages="@ExportAllPages" />
79+
<GridCsvExport FileName="telerik-grid-export" />
6080
</GridExport>
6181
6282
<GridColumns>
@@ -72,19 +92,17 @@ Optionally, you can also set the `GridCsvExport` tag settings under the `GridExp
7292
@code {
7393
private List<SampleData> GridData { get; set; }
7494
75-
private bool ExportAllPages { get; set; }
76-
7795
protected override void OnInitialized()
7896
{
7997
GridData = Enumerable.Range(1, 100).Select(x => new SampleData
80-
{
81-
ProductId = x,
82-
ProductName = $"Product {x}",
83-
UnitsInStock = x * 2,
84-
Price = 3.14159m * x,
85-
Discontinued = x % 4 == 0,
86-
FirstReleaseDate = DateTime.Now.AddDays(-x)
87-
}).ToList();
98+
{
99+
ProductId = x,
100+
ProductName = $"Product {x}",
101+
UnitsInStock = x * 2,
102+
Price = 3.14159m * x,
103+
Discontinued = x % 4 == 0,
104+
FirstReleaseDate = DateTime.Now.AddDays(-x)
105+
}).ToList();
88106
}
89107
90108
public class SampleData
@@ -194,24 +212,15 @@ To customize the exported file, handle the `OnBeforeExport` or `OnAfterExport` e
194212

195213
The component allows you to control the data set that will be exported. It also provides built-in customization options for the columns, such as `Width`, `Title`, and more.
196214

197-
For more advanced customizations (such as coloring the headers, bolding the titles, or even changing cell values) the Grid lets you get the `MemoryStream` of the file. Thus, you can customize it using the [`SpreadProcessing`](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/overview) or the [`SpreadStreamProcessing`](https://docs.telerik.com/devtools/document-processing/libraries/radspreadstreamprocessing/overview) libraries that are available with your license.
215+
For more advanced customizations (such as formatting the numbers and dates, or changing the default comma delimiter) the Grid lets you get the `MemoryStream` of the file. Thus, you can customize it using the [`SpreadProcessing`](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/overview) or the [`SpreadStreamProcessing`](https://docs.telerik.com/devtools/document-processing/libraries/radspreadstreamprocessing/overview) libraries that are available with your license.
198216

199217
[Read more about how to customize the exported file...](slug:grid-export-events)
200218

201-
## Notes
202-
203-
The CSV export has the following specifics:
204-
205-
* Column widths are not applied because a CSV document does not have such a concept. You can use any units in the grid itself, they will not be reflected in the exported document. If you need to add such structure, consider [exporting to an Excel file](slug:grid-export-excel).
206-
* Templates are not exported, because there is no provision in the framework for getting them at runtime. If a column, header or group header/footer has a template or aggregates, it will be ignored. The headers will be the `Title` of the column, the data is the data from the `Field`. If you need additional information, see if you can add it in a Field in the model, or create your own Excel file. Find a <a href="https://feedback.telerik.com/blazor/1485764-customize-the-excel-file-before-it-gets-to-the-client" target="_blank">project example on how to generate your own exported file</a>.
207-
208-
@[template](/_contentTemplates/grid/export.md#export-common-notes)
209219

210220
## See Also
211221

212-
* [Live Demo: Grid Export](https://demos.telerik.com/blazor-ui/grid/export)
213-
* [Custom cell formatting of the exported file with RadSpreadProcessing](slug:grid-kb-custom-cell-formatting-with-radspreadprocessing)
214-
* [Custom cell formatting of the exported file with RadSpreadStreamProcessing](slug:grid-kb-custom-cell-formatting-with-radspreadstreamprocessing)
215-
* [Format numbers and dates in the exported CSV file from the Grid](slug:grid-kb-number-formatting-of-the-csv-export)
216-
* [Change the default CSV delimiter (comma) during Grid export](slug:grid-kb-csv-export-change-field-delimiter)
217-
* [Blazor Grid](slug:grid-overview)
222+
* [Live Demo: Grid Export](https://demos.telerik.com/blazor-ui/grid/export)
223+
* [Format numbers and dates in the exported CSV file from the Grid](slug:grid-kb-number-formatting-of-the-csv-export)
224+
* [Change the default CSV delimiter (comma) during Grid export](slug:grid-kb-csv-export-change-field-delimiter)
225+
* [Sowing a Loader While Exporting the Grid](slug:grid-kb-show-loader-while-exporting)
226+
* [Blazor Grid](slug:grid-overview)

Diff for: components/grid/export/excel.md

+53-35
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Export to Excel the Grid for Blazor.
55
slug: grid-export-excel
66
tags: telerik,blazor,grid,export,excel
77
published: True
8-
position: 1
8+
position: 5
99
---
1010

1111
# Grid Excel Export
@@ -14,25 +14,39 @@ You can export the grid to Excel with a click of a button. The current filter, s
1414

1515
When you click the Export button, your browser will receive the resulting file.
1616

17+
>tip Make sure to get familiar with all the [general export documentation first](slug:grid-export-overview).
1718
1819
#### In This Article
1920

2021
- [Basics](#basics)
2122
- [Programmatic Export](#programmatic-export)
2223
- [Customization](#customization)
23-
- [Notes](#notes)
2424

2525
## Basics
2626

27-
To enable the Grid Excel Export, add a [command button](slug:components/grid/columns/command) with the `ExcelExport` command name to the [Grid toolbar](slug:components/grid/features/toolbar).
27+
To enable the Excel export in the Grid:
28+
29+
1. [Add the Export Tool](#add-the-export-tool)
30+
1. [Configure the Export Settings](#configure-the-export-settings)
31+
1. [Set the Columns Width in Pixels](#set-the-columns-width-in-pixels)
32+
33+
### Add the Export Tool
34+
35+
Add the `GridToolBarExcelExportTool` inside the [`<GridToolBar>`](slug:components/grid/features/toolbar#command-tools):
2836

2937
````RAZOR.skip-repl
30-
<GridToolBarTemplate>
31-
<GridCommandButton Command="ExcelExport" Icon="@SvgIcon.FileExcel">Export to Excel</GridCommandButton>
32-
</GridToolBarTemplate>
38+
<GridToolBar>
39+
<GridToolBarExcelExportTool>
40+
Export to Excel
41+
</GridToolBarExcelExportTool>
42+
</GridToolBar>
3343
````
3444

35-
Optionally, you can also set the `GridExcelExport` tag settings under the `GridExport` tag to subscribe to the [Grid export events](slug:grid-export-events) that allow further customization of the exported columns/data or configure the Excel export options:
45+
If you have a custom Toolbar, add a command button with the `ExcelExport` command name inside a [templated Grid Toolbar](slug:components/grid/features/toolbar#custom-toolbar-configuration)(`<GridToolBarTemplate>`).
46+
47+
### Configure the Export Settings
48+
49+
To configure the Excel export settings, add the `GridExcelExport` tag under the `GridExport` tag. You may set the following options:
3650

3751
@[template](/_contentTemplates/common/parameters-table-styles.md#table-layout)
3852

@@ -41,22 +55,37 @@ Optionally, you can also set the `GridExcelExport` tag settings under the `GridE
4155
| `FileName` | `string` | The name of the file. The grid will add the `.xslx` extension for you. |
4256
| `AllPages` | `bool` | Whether to export the current page only, or the entire data from the data source. |
4357

44-
>caption Export the Grid to Excel - Example
58+
For further customizations, use the `GridExcelExport` tag to subscribe to the [Grid export events](slug:grid-export-events).
59+
60+
### Set the Columns Width in Pixels
61+
62+
The export to Excel does not require that all columns have explicit widths set. However, if you do set the column widths, ensure you use only `px`.
63+
64+
Excel cannot parse units different than `px` (e.g., `rem` or `%`) and renders a collapsed (hidden) column with zero width. This is an Excel limitation. If you prefer to use different than `px` units in the UI, handle the [`OnBeforeExport` event to provide the column width in pixels for the proper export](slug:grid-export-events#for-excel-export).
65+
66+
>caption Export the Grid to Excel
4567
4668
````RAZOR
4769
@* You can sort, group, filter, page the grid, resize and reodrder its columns, and you can click the
4870
Export button to save the current data *@
4971
50-
<TelerikGrid Data="@GridData" Pageable="true" Sortable="true" Resizable="true" Reorderable="true"
51-
FilterMode="@GridFilterMode.FilterRow" Groupable="true" >
72+
<TelerikGrid Data="@GridData"
73+
Pageable="true"
74+
Sortable="true"
75+
Resizable="true"
76+
Reorderable="true"
77+
FilterMode="@GridFilterMode.FilterRow"
78+
Groupable="true"
79+
Width="1200px">
5280
53-
<GridToolBarTemplate>
54-
<GridCommandButton Command="ExcelExport" Icon="@SvgIcon.FileExcel">Export to Excel</GridCommandButton>
55-
<label class="k-checkbox-label"><TelerikCheckBox @bind-Value="@ExportAllPages" />Export All Pages</label>
56-
</GridToolBarTemplate>
81+
<GridToolBar>
82+
<GridToolBarExcelExportTool>
83+
Export to Excel
84+
</GridToolBarExcelExportTool>
85+
</GridToolBar>
5786
5887
<GridExport>
59-
<GridExcelExport FileName="telerik-grid-export" AllPages="@ExportAllPages" />
88+
<GridExcelExport FileName="telerik-grid-export" />
6089
</GridExport>
6190
6291
<GridColumns>
@@ -72,19 +101,17 @@ Optionally, you can also set the `GridExcelExport` tag settings under the `GridE
72101
@code {
73102
private List<SampleData> GridData { get; set; }
74103
75-
private bool ExportAllPages { get; set; }
76-
77104
protected override void OnInitialized()
78105
{
79106
GridData = Enumerable.Range(1, 100).Select(x => new SampleData
80-
{
81-
ProductId = x,
82-
ProductName = $"Product {x}",
83-
UnitsInStock = x * 2,
84-
Price = 3.14159m * x,
85-
Discontinued = x % 4 == 0,
86-
FirstReleaseDate = DateTime.Now.AddDays(-x)
87-
}).ToList();
107+
{
108+
ProductId = x,
109+
ProductName = $"Product {x}",
110+
UnitsInStock = x * 2,
111+
Price = 3.14159m * x,
112+
Discontinued = x % 4 == 0,
113+
FirstReleaseDate = DateTime.Now.AddDays(-x)
114+
}).ToList();
88115
}
89116
90117
public class SampleData
@@ -199,19 +226,10 @@ For more advanced customization (such as coloring the headers or bolding the tit
199226

200227
Read more about how to [customize the exported file](slug:grid-export-events).
201228

202-
## Notes
203-
204-
The Excel export has the following specifics:
205-
206-
* Excel does not understand units different than `px` for the column `Width`, and if you use them (such as `rem` or `%`), it will fail to parse them and will render a collapsed (hidden) column with zero width.
207-
* Templates are not exported, because there is no provision in the framework for getting them at runtime. If a column, header or group header/footer has a template or aggregates, it will be ignored. The headers will be the `Title` of the column, the data is the data from the `Field`. If you need additional information, see if you can add it in a Field in the model, or create your own Excel file. Find a <a href="https://feedback.telerik.com/blazor/1485764-customize-the-excel-file-before-it-gets-to-the-client" target="_blank">project example on how to generate your own exported file</a>. Find additional information on how to [export an image that is rendered in a Grid column template](slug:grid-export-image-column-excel).
208-
209-
@[template](/_contentTemplates/grid/export.md#export-common-notes)
210-
211-
212229
## See Also
213230

214231
* [Live Demo: Grid Export](https://demos.telerik.com/blazor-ui/grid/export)
215232
* [Custom Cell Formatting of the Exported File with RadSpreadProcessing](slug:grid-kb-custom-cell-formatting-with-radspreadprocessing)
216233
* [Custom Cell Formatting of the Exported File with RadSpreadStreamProcessing](slug:grid-kb-custom-cell-formatting-with-radspreadstreamprocessing)
234+
* [Showing a Loader While Exporting the Grid](slug:grid-kb-show-loader-while-exporting)
217235
* [Blazor Grid](slug:grid-overview)

0 commit comments

Comments
 (0)