Skip to main content

Built-in Export

  • 2 minutes to read

The ASP.NET MVC CardView extension allows users to export 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 Built-in Exporting 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.

settings.SettingsExport.EnableClientSideExportAPI = true;
settings.Toolbars.Add(t => {
    t.EnableAdaptivity = true;
    t.Items.Add(CardViewToolbarCommand.ExportToPdf);
    t.Items.Add(CardViewToolbarCommand.ExportToDocx);
});

Exporting API

Call the client ExportTo(format) method to implement grid data exporting.

@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: