Back to Devexpress

JsonDataSource.RootElement Property

corelibraries-devexpress-dot-dataaccess-dot-json-dot-jsondatasource-f980d90b.md

latest6.5 KB
Original Source

JsonDataSource.RootElement Property

Gets or sets the name of the root element in the associated data source.

Namespace : DevExpress.DataAccess.Json

Assembly : DevExpress.DataAccess.v25.2.dll

NuGet Package : DevExpress.DataAccess

Declaration

csharp
[DefaultValue("")]
public string RootElement { get; set; }
vb
<DefaultValue("")>
Public Property RootElement As String

Property Value

TypeDefaultDescription
StringString.Empty

The root element’s name.

|

Remarks

This property is used to determine the element in the target JSON object from which data should be retrieved.

This property is set to the root element of the target JSON object by default. You can set this property to any JSON node included in the retrieved JSON data.

Note

The BI Dashboard does not support collection field types. Make sure that the root of a JSON data source has a property with a non-collection type.

If you need to use multiple collections in a single data source, merge them into a single data source. To do this, use the DashboardFederationDataSource class to create a Transformation Query.

The following code snippets (auto-collected from DevExpress Examples) contain references to the RootElement property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-dashboard-json-data-source/CS/DashboardJsonExample/Form1.cs#L51

csharp
jsonDataSource.JsonSource = new UriJsonSource(new Uri("https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json"));
jsonDataSource.RootElement = "Customers";
jsonDataSource.Fill();

asp-net-core-dashboard-register-data-sources/CS/WebDashboardDataSources/Configuration/JsonDataSourceConfigurator.cs#L14

csharp
jsonDataSourceUrl.ConnectionName = "jsonUrlConnection";
jsonDataSourceUrl.RootElement = "Customers";
storage.RegisterDataSource("jsonDataSourceUrl", jsonDataSourceUrl.SaveToXml());

asp-net-web-forms-dashboard-register-data-sources/CS/WebFormsDashboardDataSources/Pages/JsonDashboard.aspx.cs#L22

csharp
jsonDataSourceUrl.ConnectionName = "jsonUrlConnection";
jsonDataSourceUrl.RootElement = "Employee";
dataSourceStorage.RegisterDataSource("jsonDataSourceUrl", jsonDataSourceUrl.SaveToXml());

asp-net-mvc-dashboard-register-data-sources/CS/MvcDashboardDataSources/Configuration/JsonDataSourceConfigurator.cs#L13

csharp
jsonDataSourceUrl.JsonSource = new UriJsonSource(new Uri("https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json"));
jsonDataSourceUrl.RootElement = "Customers";
jsonDataSourceUrl.Fill();

DashboardUserBasedAspNetCore/CS/Code/CustomDataSourceStorage.cs#L43

csharp
jsonDataSource.JsonSource = new UriJsonSource(new System.Uri("https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json"));
jsonDataSource.RootElement = "Customers";

winforms-dashboard-json-data-source/VB/DashboardJsonExample/Form1.vb#L48

vb
jsonDataSource.JsonSource = New UriJsonSource(New Uri("https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json"))
jsonDataSource.RootElement = "Customers"
jsonDataSource.Fill()

asp-net-web-forms-dashboard-register-data-sources/VB/WebFormsDashboardDataSources/Pages/JsonDashboard.aspx.vb#L22

vb
jsonDataSourceUrl.ConnectionName = "jsonUrlConnection"
jsonDataSourceUrl.RootElement = "Employee"
dataSourceStorage.RegisterDataSource("jsonDataSourceUrl", jsonDataSourceUrl.SaveToXml())

asp-net-mvc-dashboard-register-data-sources/VB/MvcDashboardDataSources/Configuration/JsonDataSourceConfigurator.vb#L13

vb
jsonDataSourceUrl.JsonSource = New UriJsonSource(New Uri("https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json"))
jsonDataSourceUrl.RootElement = "Customers"
jsonDataSourceUrl.Fill()

See Also

JsonDataSource Class

JsonDataSource Members

DevExpress.DataAccess.Json Namespace