Skip to content

Customizes Report and Data Source Wizards. The example modifies the start page and restricts available SQL data source providers to MSSQLServer, Oracle, Amazon Redshift, MySQL, Postgres, and SQLite.

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/reporting-wpf-designer-data-provider-list

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reporting for WPF - Customize the Data Providers List in the Data Source Wizard

The example customizes the Report Wizard and Data Source Wizard to achieve the following:

  • Display ChooseDataProviderPage ("Select a Data Connection Type") as the start page.
  • Restrict available SQL data source providers to MSSQLServer, Oracle, Amazon Redshift, MySQL, Postgres, and SQLite.

Implementation Details

Customization Service

To customize Data Source and Report Wizards, create a customization service (MyWizardCustomizationService in this example) that implements the IWizardCustomizationService interface.

CustomizeDataSourceWizard and CustomizeReportWizard methods contain main logic for wizard customization:

  • StartPage - sets the wizard start page to ChooseDataProviderPage ("Select a Data Connection Type").
  • ReportType - specifies the report type in the report model.
  • DataSourceType - specifies the data source type in the report model.

The CustomizeProviders method limits available data source types and providers to a predefined list.

// ...
// Сustomization service for the Data Source and Report wizards.
public class MyWizardCustomizationService : IWizardCustomizationService {

    static readonly string[] allowedSqlDataSourceProviders = new[] {
        "MSSqlServer", "Oracle", "Amazon Redshift", "MySql", "Postgres", "SQLite"
    };
    // Modifies the Data Source wizard's start page and data source type. 
    void IDataSourceWizardCustomizationService.CustomizeDataSourceWizard(DataSourceWizardCustomizationModel customization, ViewModelSourceIntegrityContainer container) {
        if(customization.StartPage == typeof(ChooseExistingConnectionPage<IDataSourceModel>)) {
            customization.Model.DataSourceType = DataSourceType.Xpo;
            customization.StartPage = typeof(ChooseDataProviderPage<IDataSourceModel>);
        }
        CustomizeProviders(container);
    }
    // Modifies the Report wizard's start page, data source type, and report type.
    void IWizardCustomizationService.CustomizeReportWizard(ReportWizardCustomizationModel customization, ViewModelSourceIntegrityContainer container) {
        if (customization.StartPage == typeof(ChooseReportTypePage<XtraReportModel>)) {
            customization.Model.ReportType = ReportType.Standard;
            customization.Model.DataSourceType = DataSourceType.Xpo;
            customization.StartPage = typeof(ChooseDataProviderPage<XtraReportModel>);
        }
        CustomizeProviders(container);
    }
    // ...
    // Filters available SQL data source providers and registers allowed providers in the container.
    static void CustomizeProviders(IntegrityContainer container) {
        var providers = container.Resolve<List<ProviderLookupItem>>();
        providers.RemoveAll(x => !allowedSqlDataSourceProviders.Contains(x.ProviderKey));
        container.RegisterInstance<DataSourceTypes>(new DataSourceTypes(WizardDataSourceType.Sql));
    }
}

Service Registration

The ReportDesigner.ServicesRegistry property registers the MyWizardCustomizationService type in XAML and applies customization logic.

<dxrud:ReportDesigner x:Name="reportDesigner">
    <dxrud:ReportDesigner.ServicesRegistry>
        <dxda:TypeEntry ServiceType="{x:Type dxrudw:IWizardCustomizationService}" ConcreteType="{x:Type local:MyWizardCustomizationService}" />
    </dxrud:ReportDesigner.ServicesRegistry>
</dxrud:ReportDesigner>

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Customizes Report and Data Source Wizards. The example modifies the start page and restricts available SQL data source providers to MSSQLServer, Oracle, Amazon Redshift, MySQL, Postgres, and SQLite.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 5