How to Customize the Data Source Wizard
- 3 minutes to read
The Data Source Wizard allows you to establish a connection and select data from various sources. You can use the DashboardDesigner.DataSourceWizard property to customize this wizard to skip certain pages, specify the list of available data providers, and so on.
The Data Source Wizard consists of the following pages:
The first page allows users to specify the name of the data source.
The WinForms Designer does not show this page by default. To display it, use the DashboardDesignerDataSourceWizardSettings.ShowDataSourceNamePage property.
The next page allows users to select the data source type.
This page does not contain the Entity Framework, eXpress Persistent Objects (XPO), Object Binding, and MongoDB by default. To customize the list of displayed data source types, use the DashboardDesignerDataSourceWizardSettings.AvailableDataSourceTypes property.
The next paragraphs describe wizard pages related to specific data source types.
Database
The following page allows users to select connections specified in the application configuration file:
The Data Source Wizard does not show this page by default. To display this page, set the DashboardDesignerDataSourceWizardSettings.ShowConnectionsFromAppConfig property to true.
Important
Note that you can disable the creation of new connections in the Data Source Wizard. For this, use the SqlWizardSettings.DisableNewConnections property. In this case, users can only select the data connection specified in the application configuration file.
If a user selected No, I’d like to specify the connection parameters myself option on the previous page, the following page is shown:
This page allows users to select the SQL data provider and specify connection parameters. Use the SqlWizardSettings.AvailableDataProviders property to customize the list of available data providers.
The next page allows users to decide whether user credentials are saved in a dashboard definition.
The SqlWizardSettings.DatabaseCredentialsSavingBehavior property allows you to save user credentials.
The final page of the Data Source Wizard allows users to invoke the Query Builder and select data.
Note that the Data Source Wizard and Query Builder do not allow users to specify SQL queries. To enable this feature, set the SqlWizardSettings.EnableCustomSql property to true.
Warning
The use of custom SQL queries can lead to inadvertent or unauthorized modifications to your data/database structure. Ensure that you follow best practices and implement the appropriate user read/write privileges at database level.
Entity Framework
For the Entity Framework data source, the invoked page allows users to select data context.
If necessary, you can allow users to choose a custom assembly that contains a data context. To do this, enable the EFWizardSettings.ShowBrowseButton flag to add the Browse button to this page. Then, handle the EFDataSource.BeforeLoadCustomAssemblyGlobal event to manage custom assembly loading.