Skip to main content
A newer version of this page is available. .

Specify Data Source Settings (JSON)

  • 3 minutes to read

Select an Existing Data Connection

The “Choose a data connection” page appears if you select JSON on the start page. Select an existing connection from the list.

Click Next to proceed to the “Select Data Fields” page.

Create a New Data Connection

You can provide end users with the capability to create a new data connection for a JSON Data Source at runtime.

On the server side, implement the IDataSourceWizardConnectionStringsStorage interface to provide an end user with the capability to save the created JSON data connections. Use the created class instance as the ASPxDashboard.SetConnectionStringsProvider / DashboardConfigurator.SetConnectionStringsProvider method’s parameter.

The following code snippet shows how to save the created connection strings in the context of the ASP.NET Core dashboard application.

using DevExpress.DashboardWeb;
using DevExpress.DataAccess.ConnectionParameters;
using System.Collections.Generic;
using System.Linq;

// ...

public void ConfigureServices(IServiceCollection services) {
  services
    .AddMvc()
    .AddDefaultDashboardController((configurator, serviceProvider)  => {
      // Use the ConnectionStringProvider instance as the SetConnectionStringsProvider method's parameter.
      configurator.SetConnectionStringsProvider(new ConnectionStringProvider());
      // ...
    });

  services.AddDevExpressControls();
}
public class ConnectionStringProvider: IDataSourceWizardConnectionStringsStorage {
    readonly Dictionary<string, DataConnectionParametersBase> storage = new Dictionary<string, DataConnectionParametersBase>();
    public Dictionary<string, string> GetConnectionDescriptions() {
      return storage.ToDictionary(p=>p.Key, p=>p.Key);
    }
    public DataConnectionParametersBase GetDataConnectionParameters(string name) {
      return storage[name];
    }
    public void SaveDataConnectionParameters(string name, DataConnectionParametersBase connectionParameters, bool saveCredentials) {
        storage[name] = connectionParameters;
    }
}

To enable the capability for end users, set the allowCreateNewJsonConnection property to true:

Platform API
HTML JavaScript DataSourceWizardExtensionOptions.allowCreateNewJsonConnection
ASP.NET Core DataSourceWizardOptionBuilder.AllowCreateNewJsonConnection
MVC DashboardExtensionSettings.AllowCreateNewJsonConnection
Web Forms ASPxDashboard.AllowCreateNewJsonConnection

After that, select a new data connection on the “Choose Connection (JSON)” page:

Configure a New Data Connection

On the next page, configure a new data connection:

Specify the connection name and select the JSON source type.

  • Web Service Endpoint (URI)

    A URL to a file in the JSON format. You can also specify the Web Service Endpoint’s request parameters (username and password, HTTP headers, or query parameters)

  • JSON String

    A string that contains JSON data. You can also use the Upload JSON button to load content from the selected JSON file.

Click Next to proceed to the “Select Data Fields” page.

Select Data Fields

The “Select data fields” page allows you to include / exclude data fields used in a JSON data source.

Click Finish to create a JSON data source.

API

The database wizard pages are identified by the following API:

Page Name Page ID Class
Choose Connection (JSON) JsonDataSourceWizardPageId.ChooseConnectionPage ChooseJsonConnectionPage
Choose JSON Source JsonDataSourceWizardPageId.ChooseJsonSourcePage ChooseJsonSourcePage
Select Data Fields JsonDataSourceWizardPageId.ChooseJsonSchemaPage ChooseJsonSchemaPage
See Also