Skip to content

Commit 4dcc00d

Browse files
committed
chore(grid): final
1 parent 8c2a1bb commit 4dcc00d

File tree

3 files changed

+33
-31
lines changed

3 files changed

+33
-31
lines changed

components/grid/export/csv.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ Optionally, you can also set the `GridCsvExport` tag settings under the `GridExp
3838

3939
| Parameter | Type and Default Value | Description |
4040
| --- | --- | --- |
41-
4241
| `FileName` | `string` | The name of the file. The grid will add the `.csv` extension for you. |
4342
| `AllPages` | `bool` | Whether to export the current page only, or the entire data from the data source. |
4443

components/grid/export/events.md

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,12 @@ To export a hidden Grid column that has its `Visible` parameter set to `false`,
200200
</TelerikGrid>
201201
202202
@code {
203+
private IEnumerable<object> SelectedItems = Enumerable.Empty<object>();
204+
205+
private List<SampleData> GridData { get; set; }
206+
207+
private bool ExportAllPages { get; set; }
208+
203209
private async Task OnBeforeCsvExport(GridBeforeCsvExportEventArgs args)
204210
{
205211
//export the SelectedItems
@@ -221,11 +227,6 @@ To export a hidden Grid column that has its `Visible` parameter set to `false`,
221227
args.IsCancelled = false;
222228
}
223229
224-
private IEnumerable<object> SelectedItems = Enumerable.Empty<object>();
225-
226-
List<SampleData> GridData { get; set; }
227-
bool ExportAllPages { get; set; }
228-
229230
protected override void OnInitialized()
230231
{
231232
GridData = Enumerable.Range(1, 100).Select(x => new SampleData
@@ -425,19 +426,20 @@ The `OnAfterExport` event fires after [OnBeforeExport](#onbeforeexport) and befo
425426
</TelerikGrid>
426427
427428
@code {
429+
private MemoryStream excelStream { get; set; }
430+
431+
private IEnumerable<object> SelectedItems = Enumerable.Empty<object>();
432+
433+
private List<SampleData> GridData { get; set; }
434+
435+
private bool ExportAllPages { get; set; }
436+
428437
private async Task OnExcelAfterExport(GridAfterExcelExportEventArgs args)
429438
{
430439
var bytes = args.Stream.ToArray();
431440
var excelStream = new MemoryStream(bytes);
432441
}
433442
434-
private MemoryStream excelStream { get; set; }
435-
436-
private IEnumerable<object> SelectedItems = Enumerable.Empty<object>();
437-
438-
List<SampleData> GridData { get; set; }
439-
bool ExportAllPages { get; set; }
440-
441443
protected override void OnInitialized()
442444
{
443445
GridData = Enumerable.Range(1, 100).Select(x => new SampleData
@@ -502,19 +504,20 @@ The `OnAfterExport` event fires after [OnBeforeExport](#onbeforeexport) and befo
502504
</TelerikGrid>
503505
504506
@code {
507+
private MemoryStream csvStream { get; set; }
508+
509+
private IEnumerable<object> SelectedItems = Enumerable.Empty<object>();
510+
511+
private List<SampleData> GridData { get; set; }
512+
513+
private bool ExportAllPages { get; set; }
514+
505515
private async Task OnCSVAfterExport(GridAfterCsvExportEventArgs args)
506516
{
507517
var bytes = args.Stream.ToArray();
508518
var excelStream = new MemoryStream(bytes);
509519
}
510520
511-
private MemoryStream csvStream { get; set; }
512-
513-
private IEnumerable<object> SelectedItems = Enumerable.Empty<object>();
514-
515-
List<SampleData> GridData { get; set; }
516-
bool ExportAllPages { get; set; }
517-
518521
protected override void OnInitialized()
519522
{
520523
GridData = Enumerable.Range(1, 100).Select(x => new SampleData
@@ -583,12 +586,6 @@ The `OnAfterExport` event fires after [OnBeforeExport](#onbeforeexport) and befo
583586
</TelerikGrid>
584587
585588
@code {
586-
private async Task OnAfterPDFExport(GridAfterPdfExportEventArgs args)
587-
{
588-
var bytes = args.Stream.ToArray();
589-
var pdfStream = new MemoryStream(bytes);
590-
}
591-
592589
private MemoryStream pdfStream { get; set; }
593590
594591
private IEnumerable<object> SelectedItems = Enumerable.Empty<object>();
@@ -597,6 +594,12 @@ The `OnAfterExport` event fires after [OnBeforeExport](#onbeforeexport) and befo
597594
598595
private bool ExportAllPages { get; set; }
599596
597+
private async Task OnAfterPDFExport(GridAfterPdfExportEventArgs args)
598+
{
599+
var bytes = args.Stream.ToArray();
600+
var pdfStream = new MemoryStream(bytes);
601+
}
602+
600603
protected override void OnInitialized()
601604
{
602605
GridData = Enumerable.Range(1, 100).Select(x => new SampleData

components/grid/export/pdf.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ position: 1
1010

1111
# PDF Export
1212

13-
You can export the grid to PDF with a click of a button. The current filter, sort, page, grouping, column order and column size are applied to the exported PDF document.
13+
You can export the Grid to PDF with a click of a button. The current filter, sort, page, grouping, column order and column size are applied to the exported PDF document.
1414

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

@@ -38,7 +38,7 @@ Optionally, you can also set the `GridPdfExport` tag settings under the `GridExp
3838

3939
| Parameter | Type and Default&nbsp;Value | Description |
4040
| --- | --- | --- |
41-
| `FileName` | `string` | The name of the file. The grid will add the `.pdf` extension for you. |
41+
| `FileName` | `string` | The name of the file. The Grid will add the `.pdf` extension for you. |
4242
| `AllPages` | `bool` | Whether to export the current page only, or the entire data from the data source. |
4343
| `PaperSize` | `GridPdfExportPaperSize` enum <br/> (`A4`) | The size of the paper for the exported file. |
4444
| `PageOrientation` | `GridPdfExportPageOrientation` enum <br/> (`Portrait`)| The orientation of the page - portrait and landscape. |
@@ -206,10 +206,10 @@ Read more about how to [customize the exported file](slug:grid-export-events).
206206

207207
The PDF export has the following specifics:
208208

209-
* When exporting grid columns, the developer must provide column widths that are appropriate for exporting the data. While an Excel file allows resizing its columns, the PDF file format does not allow resizing the columns. The width of the column can be changed from the `OnBeforeExportEventArgs.Columns[0].Width property`, so developers have full control over this value (note that it can be different from the one defined in the corresponding grid column, thus ensuring flexibility to render the grid columns with one widths and export them in others).
210-
* We do not recommend exporting columns without widths - while Excel has a default width for a column, PDF requires fixed dimensions. We recommend setting specific widths to all columns when exporting (note that this is unrelated to the width of the column of the grid as the export width can be configured in `OnBeforeExportEventArgs.Columns[0].Width` property.
209+
* When exporting Grid columns, the developer must provide column widths that are appropriate for exporting the data. While an Excel file allows resizing its columns, the PDF file format does not allow resizing the columns. You can change the width of the column from the [`OnBeforeExportEventArgs.Columns[0].Width property`](slug://grid-export-events#for-pdf-export), so you have full control over this value (note that it can be different from the one defined in the corresponding Grid column, thus ensuring flexibility to render the Grid columns with one width and export them in other).
210+
* We do not recommend exporting columns without widths - while Excel has a default width for a column, PDF requires fixed dimensions. We recommend setting specific widths to all columns when exporting (note that this is unrelated to the width of the column as the export width can be configured through the [`OnBeforeExport` event](slug://grid-export-events#for-pdf-export).
211211
* PDF 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.
212-
* When exporting grid columns, the developer must provide appropriate `PaperSize` and `PageOrientation` properties. For example, if you want to render 20 columns (100px each) in a A4 sheet, then this will yield unexpected results. The column dimensions in a PDF file are fixed, thus they cannot be resized as in Excel, which requires the developer to ensure proper export dimensions.
212+
* When exporting Grid columns, you must provide appropriate `PaperSize` and `PageOrientation` properties. For example, if you want to render 20 columns (100px each) in a A4 sheet, then this will yield unexpected results. The column dimensions in a PDF file are fixed, thus they cannot be resized as in Excel, which requires the developer to ensure proper export dimensions.
213213
* Exporting to PDF in UI for Blazor is different from exporting in Kendo jQuery, where the full HTML is exported. The Blazor export to PDF will export the Grid to a table, similar to an Excel table. If you want [to export to PDF as HTML, you can use a custom approach](#custom-export).
214214
* 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 PDF file. Find a <a href="https://feedback.telerik.com/blazor/1485764-customize-the-Pdf-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-Pdf).
215215

0 commit comments

Comments
 (0)