DashboardObjectDataSource Class

An object data source that provides data for the dashboard.

Namespace: DevExpress.DashboardCommon

Assembly: DevExpress.Dashboard.v21.2.Core.dll

Declaration

[DataAccessMetadata("All", SupportedProcessingModes = "Simple", EnableBindingToObjectDataSource = true, PreferAsyncDataLoading = false)]
public class DashboardObjectDataSource :
    ObjectDataSource,
    IDashboardDataSource,
    IDashboardComponent,
    IComponent,
    IDisposable,
    ISupportInitialize,
    ISupportPrefix,
    IDashboardDataSourceInternal,
    IExternalSchemaConsumer,
    IFederationDataProvider,
    IFederationDataSchemaProvider

Remarks

To provide data for the DashboardObjectDataSource, assign the type of the required class to the DataSource property and set the DataMember property specifying the data member used to obtain the required data.

Handle the following events to supply the dashboard with actual data at runtime:

Platform Event
ASP.NET ASPxDashboard.DataLoading, DashboardConfigurator.DataLoading
WinForms DashboardDesigner.DataLoading, DashboardViewer.DataLoading
WinForms, in Async Mode DashboardDesigner.AsyncDataLoading, DashboardViewer.AsyncDataLoading
WPF DashboardControl.AsyncDataLoading
Any platform, not in Async Mode Dashboard.DataLoading

An object that provides data should implement the IEnumerable or IListSource interface.

Tip

You can create a custom fill service with the IObjectDataSourceCustomFillService interface, get access to the DashboardObjectDataSource configuration and use configuration parameters to modify the current data query.

Example

The following example demonstrates how to bind a dashboard to a List object.

The quantity values are provided at runtime. The dashboard data source is added to the Dashboard.DataSources collection on the first load.

Click the Reload Data button to call the DashboardViewer.ReloadData method. It raises the DashboardViewer.DataLoading event and supplies the dashboard with updated data.

win-dashboard-bind-to-list-object

View Example: How to Bind a Dashboard to a List of Objects

using System;
using System.Collections.Generic;
using System.Threading;

namespace Dashboard_BindingToList {
    public class Data {
        public string SalesPerson { get; set; }
        public int Quantity { get; set; }

        public static List<Data> CreateData() {
            List<Data> data = new List<Data>();
            string[] salesPersons = { "Andrew Fuller", "Michael Suyama", "Robert King", "Nancy Davolio",
                "Margaret Peacock", "Laura Callahan", "Steven Buchanan", "Janet Leverling" };

            for (int i = 0; i < 100; i++) {
                Data record = new Data();
                int seed = (int)DateTime.Now.Ticks & 0x0000FFFF;
                record.SalesPerson = salesPersons[new Random(seed).Next(0, salesPersons.Length)];
                record.Quantity = new Random(seed).Next(0, 100);
                data.Add(record);
                Thread.Sleep(3);
            }
            return data;
        }
    }
}

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

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.

See Also