Skip to main content
.NET 6.0+

ExportController.ExportActionItemsCreated Event

Occurs after the Export Action’s ChoiceActionBase.Items collection has been populated.

Namespace: DevExpress.ExpressApp.SystemModule

Assembly: DevExpress.ExpressApp.v23.2.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public event EventHandler<EventArgs> ExportActionItemsCreated

Event Data

The ExportActionItemsCreated event's data class is EventArgs.

Remarks

By default, the Export Action’s Items collection is populated based on the IExportable.SupportedExportFormats list of the Controller’s ExportController.Exportable editor. To customize the Items collection after it’s been populated, handle the ExportActionItemsCreated event. Note that the exporter used by default can only export data to the formats specified by the ExportTarget enumeration. So, the Action’s Items must be of the ExportTarget type only, if you use the default export.

Note

If the control of the Controller’s ExportController.Exportable Editor doesn’t implement the IPrintable interface or the Exportable Editor is not specified, the Export Action’s Items collection remains empty, the ExportActionItemsCreated event is not raised and the Export Action is not activated.

The following code demonstrates how to place the required item to the first place in the Export Action’s Items collection:

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.SystemModule;
using DevExpress.XtraPrinting;
//...
public class MyExportViewController : ViewController<ListView> {
    private ExportController exportController;

    protected override void OnActivated() {
        base.OnActivated();
        exportController = Frame.GetController<ExportController>();
        if(exportController != null) {
            exportController.ExportActionItemsCreated += ExportController_ExportActionItemsCreated;
        }
    }
    private void ExportController_ExportActionItemsCreated(object sender, EventArgs e) {
        var exportAction = exportController.ExportAction;
        if(exportAction.Items.FirstActiveItem != null && (ExportTarget)exportAction.Items.FirstActiveItem.Data != ExportTarget.Xls) {
            ChoiceActionItem item = exportAction.Items.Find(ExportTarget.Xls);
            exportAction.Items.Remove(item);
            exportAction.Items.Insert(0, item);
        }
    }
    protected override void OnDeactivated() {
        base.OnDeactivated();
        if(exportController != null) {
            exportController.ExportActionItemsCreated -= ExportController_ExportActionItemsCreated;
        }
    }
}
See Also