Back to Devexpress

ASPxDashboard.CustomExport Event

dashboard-devexpress-dot-dashboardweb-dot-aspxdashboard-353aa0a0.md

latest13.2 KB
Original Source

ASPxDashboard.CustomExport Event

Allows you to customize the exported document.

Namespace : DevExpress.DashboardWeb

Assembly : DevExpress.Dashboard.v25.2.Web.WebForms.dll

NuGet Package : DevExpress.Web.Dashboard

Declaration

csharp
public event CustomExportWebEventHandler CustomExport
vb
Public Event CustomExport As CustomExportWebEventHandler

Event Data

The CustomExport event's data class is CustomExportWebEventArgs. The following properties provide information specific to this event:

PropertyDescription
DashboardIdGets the identifier of the exported dashboard. Inherited from CustomExportBaseWebEventArgs.
ExportActionGets the export action performed by an end-user. Inherited from CustomExportBaseWebEventArgs.
ExportModeGets the document export mode. Inherited from CustomExportBaseWebEventArgs.
ImageExportOptionsGets export options related to exporting a dashboard/dashboard item as an image. Inherited from CustomExportBaseWebEventArgs.
ImageOptionsObsolete. Gets export options related to exporting a dashboard/dashboard item as an image. Inherited from CustomExportBaseWebEventArgs.
ItemComponentNameGets the component name of the exported dashboard item. Inherited from CustomExportBaseWebEventArgs.
PdfExportOptionsGets export options related to exporting a dashboard/dashboard item to PDF format. Inherited from CustomExportBaseWebEventArgs.
PdfOptionsObsolete. Gets export options related to exporting a dashboard/dashboard item to PDF format. Inherited from CustomExportBaseWebEventArgs.
PrintableComponentsObsolete. Provides access to a dictionary containing dashboard item names and related PrintableComponents. For internal use.
ReportGets the underlying report of the exported document.

The event data class exposes the following methods:

MethodDescription
GetChartContext(String)Returns chart context for the specified Chart dashboard item.
GetDashboardItem(String)Returns a dashboard item that corresponds the specified component name.
GetGaugeContext(String)Returns gauge export context for the specified Gauge dashboard item.
GetItemData(String)Returns multidimensional data for the specified dashboard item.
GetPrintableControl(String)Gets a printable control corresponding to the specified dashboard item.
GetPrintableControls()Gets printable controls corresponding to the exported dashboard items.

Remarks

The Dashboard Control raises the CustomExport event before saving the exported document to the PDF and Image formats. The event allows you to customize the exported document.

Tip

You can also use the CustomExportWebEventArgs.Report parameter to customize the underlying report.

The following table illustrates dashboard items and their corresponding printable XRControls:

Dashboard ItemXRControl
ChartDashboardItemXRChart
ScatterChartDashboardItemXRChart
PieDashboardItemXRChart
PivotDashboardItemXRPivotGrid
RangeFilterDashboardItem (When CustomExportBaseEventArgs.ExportMode is SingleItem)XRChart
GaugeDashboardItemXRGaugeDashboardItem
TextBoxDashboardItemXRTextBox

For more information about export, see the following topic: Exporting in the Web Dashboard.

Example

The following example shows how to customize dashboard items in the exported document when you handle the ASPxDashboard.CustomExport / DashboardConfigurator.CustomExport events. You can use the CustomExportWebEventArgs.GetPrintableControls method to obtain the printable controls.

csharp
using DevExpress.DashboardCommon;
using DevExpress.DashboardWeb;
using DevExpress.XtraCharts;
using DevExpress.XtraReports.UI;
using System;
using System.Drawing;
using System.Linq;

protected void CustomizeExport(object sender, CustomExportWebEventArgs e) {
  foreach(var printControl in e.GetPrintableControls()) {
    if(printControl.Value is XRGaugeDashboardItem) {
      var gaugeItemName = printControl.Key;
      var gaugeDashboardItem = e.GetDashboardItem(gaugeItemName) as GaugeDashboardItem;
      foreach(var dashGaugeElement in gaugeDashboardItem.Gauges) {
        foreach(var gaugePanel in e.GetGaugeContext(gaugeItemName).GetPrintableGauges(dashGaugeElement).Cast<XRDashboardGauge>()) {
          if(gaugePanel != null) {
              gaugePanel.MainSeriesLabel.ForeColor = Color.Red;
          }
        }
      }
    }

    if(printControl.Value is XRChart) {
      var chartItemName = printControl.Key;
      var chartDashboardItem = e.GetDashboardItem(chartItemName) as ChartDashboardItem;
      foreach(var pane in chartDashboardItem.Panes) {
        if(pane.Series.Count > 0) {
          foreach(var dashSeries in pane.Series) {
            if(dashSeries != null) {
              var controlSeries = e.GetChartContext(chartItemName).GetControlSeries(dashSeries);
              if(controlSeries != null) {
                foreach(var ser in controlSeries) {
                  LineSeriesView view = ser.View as LineSeriesView;
                  if(view != null) {
                      view.LineStyle.DashStyle = DashStyle.DashDot;
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
vb
Imports DevExpress.DashboardCommon
Imports DevExpress.DashboardWeb
Imports DevExpress.XtraCharts
Imports DevExpress.XtraReports.UI
Imports System
Imports System.Drawing
Imports System.Linq

Protected Sub ASPxDashboard1_CustomExport(ByVal sender As Object, ByVal e As CustomExportWebEventArgs)
  For Each printControl In e.GetPrintableControls()
    If TypeOf printControl.Value Is XRGaugeDashboardItem Then
      Dim gaugeItemName = printControl.Key
      Dim gaugeDashboardItem = TryCast(e.GetDashboardItem(gaugeItemName), GaugeDashboardItem)
      For Each dashGaugeElement In gaugeDashboardItem.Gauges
        For Each gaugePanel In e.GetGaugeContext(gaugeItemName).GetPrintableGauges(dashGaugeElement).Cast(Of XRDashboardGauge)()
          If gaugePanel IsNot Nothing Then
              gaugePanel.MainSeriesLabel.ForeColor = Color.Red
          End If
        Next gaugePanel
      Next dashGaugeElement
    End If

    If TypeOf printControl.Value Is XRChart Then
      Dim chartItemName = printControl.Key
      Dim chartDashboardItem = TryCast(e.GetDashboardItem(chartItemName), ChartDashboardItem)
      For Each pane In chartDashboardItem.Panes
        If pane.Series.Count > 0 Then
          For Each dashSeries In pane.Series
            If dashSeries IsNot Nothing Then
              Dim controlSeries = e.GetChartContext(chartItemName).GetControlSeries(dashSeries)
              If controlSeries IsNot Nothing Then
                For Each ser In controlSeries
                  Dim view As LineSeriesView = TryCast(ser.View, LineSeriesView)
                  If view IsNot Nothing Then
                      view.LineStyle.DashStyle = DashStyle.DashDot
                  End If
                Next ser
              End If
            End If
          Next dashSeries
        End If
      Next pane
    End If
  Next printControl
End Sub

The following code snippets (auto-collected from DevExpress Examples) contain references to the CustomExport event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

dashboard-constant-lines/CS/ConstantLineExtension.Web/ConstantLineModule.cs#L35

csharp
targetWebDashboard.ConfigureItemDataCalculation += Web_ConfigureItemDataCalculation;
    targetWebDashboard.CustomExport += CustomExport;
}

asp-net-web-forms-dashboard-custom-properties-sample/CS/WebFormsDashboardCustomPropertiesSample/Default.aspx.cs#L17

csharp
ASPxDashboard1.CustomExport += (s, args) => {
    ChartConstantLinesExtension.CustomExport(args);

asp-net-web-forms-dashboard-custom-properties-sample/VB/WebFormsDashboardCustomPropertiesSample/Default.aspx.vb#L19

vb
AddHandler ASPxDashboard1.CustomExport,
    Sub(s, args)

See Also

CustomizeExportDocument

ASPxDashboard Class

ASPxDashboard Members

DevExpress.DashboardWeb Namespace