CustomItemExportControlCreatingEventArgs.ExportControlProvider Property
Gets or sets the object that specifies a printable control for the custom dashboard item before it is exported.
Namespace: DevExpress.DashboardCommon
Assembly: DevExpress.Dashboard.v24.1.Core.dll
NuGet Package: DevExpress.Dashboard.Core
Declaration
Property Value
Type | Description |
---|---|
ICustomExportControlProvider | A class that implements the |
Remarks
Follow the steps below to export a custom dashboard item:
Create a class that implements the ICustomExportControlProvider interface to configure a printable control that corresponds to a custom item in the dashboard.
In the DashboardExporter.CustomItemExportControlCreating event handler, assign this class instance to the
ExportControlProvider
property to use the configured printable control for a custom dashboard item’s export.
The following example shows how use the DashboardExporter component in a console application to export a dashboard with a custom Funnel item:
Implement the ICustomExportControlProvider Interface
Create a class that implements the ICustomExportControlProvider
interface (FunnelItemExportControlProvider
in this example). FunnelItemExportControlProvider
is used to configure the printable XRChart
control for the custom Funnel item in the dashboard.
The ICustomExportControlProvider.GetPrintableControl method specifies the printable XRChart
control that is used to export the custom Funnel. The method gets CustomItemExportInfo and CustomItemData objects as parameters.
The CustomItemExportInfo
object contains the custom Funnel’s export settings: ExportMode and Selection.
The ChartControl.SelectionMode
property is updated according to the master filter mode.
The SetSelection method updates the custom control based on the current master filter selection.
The ConfigureSeries
method is used to data bind and configure the custom Funnel chart’s series. The CustomItemData.GetBindings method gets a CustomItemBindingValue
collection. Each object in this collection contains information about data items stored in a custom item. The object’s UniqueId
property value can be used as a data member when a custom control is bound to data.
using System.Collections.Generic;
using System.Linq;
using DevExpress.DashboardCommon;
using DevExpress.XtraCharts;
using DevExpress.XtraReports.UI;
namespace DashboardExporterApp {
public class FunnelItemExportControlProvider : ICustomExportControlProvider {
readonly CustomDashboardItem dashboardItem;
public FunnelItemExportControlProvider(CustomDashboardItem dashboardItem) {
this.dashboardItem = dashboardItem;
}
XRControl ICustomExportControlProvider.GetPrintableControl(CustomItemData customItemData,
CustomItemExportInfo exportInfo) {
XRChart chart = new XRChart();
chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
chart.CustomDrawSeriesPoint += CustomDrawSeriesPoint;
DashboardFlatDataSource flatData = customItemData.GetFlatData(new DashboardFlatDataSourceOptions() {
AddColoringColumns = true });
ConfigureSeries(chart, customItemData, flatData, exportInfo.DrillDownValues.Count);
SetSelectionMode(chart);
SetSelection(chart, exportInfo.Selection, flatData);
return chart;
}
void ConfigureSeries(XRChart chart, CustomItemData customItemData,
DashboardFlatDataSource flatData, int drillDownLevel) {
chart.Series.Clear();
Series series = new Series("A Funnel Series", ViewType.Funnel);
IList<CustomItemBindingValue> values = customItemData.GetBindings("Value");
IList<CustomItemBindingValue> arguments = customItemData.GetBindings("Arguments");
if(values.Count > 0 && arguments.Count > 0) {
series.DataSource = flatData;
series.ValueDataMembers.AddRange(values[0].UniqueId);
if(dashboardItem.InteractivityOptions.IsDrillDownEnabled)
series.ArgumentDataMember = arguments[drillDownLevel].UniqueId;
else
series.ArgumentDataMember = arguments.Last().UniqueId;
series.ColorDataMember = flatData.GetColoringColumn(values[0].UniqueId).Name;
}
((FunnelSeriesLabel)series.Label).Position = FunnelSeriesLabelPosition.Center;
chart.Series.Add(series);
}
void SetSelectionMode(XRChart chart) {
chart.Chart.SeriesSelectionMode = SeriesSelectionMode.Point;
switch(dashboardItem.InteractivityOptions.MasterFilterMode) {
case DashboardItemMasterFilterMode.None:
chart.Chart.SelectionMode = ElementSelectionMode.None;
break;
case DashboardItemMasterFilterMode.Single:
chart.Chart.SelectionMode = ElementSelectionMode.Single;
break;
case DashboardItemMasterFilterMode.Multiple:
chart.Chart.SelectionMode = ElementSelectionMode.Extended;
break;
default:
chart.Chart.SelectionMode = ElementSelectionMode.None;
break;
}
}
void SetSelection(XRChart chart, CustomItemSelection selection,
DashboardFlatDataSource flatData) {
foreach(DashboardFlatDataSourceRow row in selection.GetDashboardFlatDataSourceRows(flatData))
chart.Chart.SelectedItems.Add(row);
}
void CustomDrawSeriesPoint(object sender, CustomDrawSeriesPointEventArgs e) {
e.LabelText = e.SeriesPoint.Argument + " - " + e.LabelText;
e.LegendText = e.SeriesPoint.Argument;
}
}
}
Handle the CustomItemExportControlCreating Event
Handle the CustomItemExportControlCreating
event and assign the FunnelItemExportControlProvider
object to the ExportControlProvider
property. The property is used to specify the printable control that corresponds to the exported custom Funnel item.
using DevExpress.DashboardCommon;
//...
DashboardExporter exporter = new DashboardExporter();
exporter.CustomItemExportControlCreating += Exporter_CustomItemExportControlCreating;
static void Exporter_CustomItemExportControlCreating(object sender,
CustomItemExportControlCreatingEventArgs e) {
if(e.CustomItemType == "FunnelItem")
e.ExportControlProvider = new FunnelItemExportControlProvider(e.DashboardItem);
}