Built-in Export
- 2 minutes to read
Note
The information in this topic applies to DevExpress ASP.NET MVC Card View version 17.2 and later.
The ASP.NET MVC CardView extension allows exporting its data to a file or stream in CSV, DOCX, PDF, RTF, XLS, and XLSX format.
MVCxCardView data exporting can be implemented using standard toolbar commands and the server and client API.
Note
Follow the instructions below to ensure the exporting functionality works correctly:
- Exporting using the built-in toolbar commands and client-side API is disabled by default due to possible security issues. To enable this functionality, set the MVCxGridExportSettings.EnableClientSideExportAPI property to true.
- The CardView extension should be inside the <form> form.
Refer to the KA18639 knowledge base article to get more information on exporting GridView rows while retaining end-user modifications (such as sorting, grouping, filtering, selection).
Standard toolbar commands
The MVCxCardView toolbar provides frequently used grid commands, including exporting commands. Specify a standard grid exporting command (listed below) using the CardViewToolbarItem.Command property setting. Refer to the Toolbar online demo for more information on using grid toolbars.
- CardViewToolbarCommand.ExportToPdf
- CardViewToolbarCommand.ExportToRtf
- CardViewToolbarCommand.ExportToCsv
- CardViewToolbarCommand.ExportToXls
- CardViewToolbarCommand.ExportToXlsx
- CardViewToolbarCommand.ExportToDocx
settings.SettingsExport.EnableClientSideExportAPI = true; settings.Toolbars.Add(t => { t.EnableAdaptivity = true; t.Items.Add(CardViewToolbarCommand.ExportToPdf); t.Items.Add(CardViewToolbarCommand.ExportToDocx); });
Exporting API
Execute an appropriate client method to implement grid data exporting. See Member Table: Built-in Export for a list of available methods.
The following example illustrates how to use client exporting methods:
@Html.DevExpress().CardView(settings => { settings.Name = "CardView"; settings.SettingsExport.EnableClientSideExportAPI = true; ... }).Bind(Model).GetHtml() ... <div class="button"> @Html.DevExpress().Button(s => { s.Name = "ExpBtn"; s.Text = "Export"; s.AutoPostBack = "false"; s.ClientSideEvents.Click = "function(s,e){ CardView.ExportTo(ASPxClientCardViewExportFormat.Pdf);}"; }).GetHtml()
Online Demos
Refer to the following online demos to see the data export in action:
Exporting Data to Different Formats