Back to Devexpress

How to: Export Only Selected Cards

aspnet-115484-components-card-view-examples-how-to-export-only-selected-cards.md

latest2.2 KB
Original Source

How to: Export Only Selected Cards

  • Dec 17, 2020

The following example exports only selected cards. To see this feature in action, refer to the following DevExpress ASP.NET Card View demo: Export Selected Records.

csharp
protected void cardView_RenderBrick(object sender, ASPxCardViewExportRenderingEventArgs e) {
    if(e.Column.FieldName == "PhotoUrl") {
        var path = MapPath(e.Value.ToString());
        if(File.Exists(path))
            e.ImageValue = File.ReadAllBytes(path);
    }
}
aspx
<dx:ASPxCardView ID="cardView" ClientInstanceName="cardView" runat="server" EnableCardsCache="false" OnExportRenderBrick="cardView_RenderBrick">
    <Toolbars>
        <dx:CardViewToolbar EnableAdaptivity="true">
            <Items>
                <dx:CardViewToolbarItem Text="Export" Image-IconID="export_export_16x16">
                    <Items>
                        <dx:CardViewToolbarItem Command="ExportToPdf" />
                        <dx:CardViewToolbarItem Command="ExportToXls" />
                        <dx:CardViewToolbarItem Command="ExportToXlsx" />
                        <dx:CardViewToolbarItem Command="ExportToDocx" />
                        <dx:CardViewToolbarItem Command="ExportToRtf" />
                    </Items>
                </dx:CardViewToolbarItem>
                <dx:CardViewToolbarItem Name="custSelectAll" Text="Select All" BeginGroup="true" />
                <dx:CardViewToolbarItem Name="custUnselectAll" Text="Unselect All" />
                <dx:CardViewToolbarItem Name="custSelectAllOnPage" Text="Select all on the page" BeginGroup="true" />
                <dx:CardViewToolbarItem Name="custUnselectAllOnPage" Text="Unselect all on the page" />
            </Items>
        </dx:CardViewToolbar>
    </Toolbars>
    <ClientSideEvents Init="function(s, e) { cardView.SelectAllCardsOnPage(); }" ToolbarItemClick="OnToolbarItemClick" />
    <Columns>
        ...
    </Columns>
    <SettingsExport EnableClientSideExportAPI="true" CardWidth="430" ExportSelectedCardsOnly="true" />
</dx:ASPxCardView>