Skip to main content

DataSource Class

A data source that provides data for the dashboard.

Declaration

export abstract class DataSource extends TypedSerializableModel implements IDashboardComponent

Remarks

The Web Dashboard does not allow you to create data sources on the client from scratch. You can use the existing data sources to supply dashboard items with data.

The following example shows how to get the existing data source from the opened dashboard and use it as a data source for dashboard items.

// Use the line below for a modular approach:
// import * as Model from 'devexpress-dashboard/model'
// Use the line below for an approach with global namespaces:
// var Model = DevExpress.Dashboard.Model;

// ...

public createDataSource() {
    var dashboard = this.webDashboard.dashboard();

    // Get the existing data sources.
    var sqlDataSource = <Model.SqlDataSource>dashboard.dataSources()[0];
    var excelDataSource = <Model.SqlDataSource>dashboard.dataSources()[1];

    // Create data items for the Grid.
    var gridCategoryName = new Model.Dimension();
    gridCategoryName.dataMember("CategoryName");
    var gridUnitPrice = new Model.Measure();
    gridUnitPrice.dataMember("UnitPrice");

    // Create the Grid dashboard item and bind it to data.
    var gridItem = new Model.GridItem();  
    gridItem.dataSource(sqlDataSource.componentName());
    gridItem.dataMember(sqlDataSource.queries()[0].name());

    // Create data items for the Geo Point Map.
    var geoPointMapImport = new Model.Measure();
    geoPointMapImport.dataMember("Import");
    var geoPointMapLatitude = new Model.Dimension();
    geoPointMapLatitude.dataMember("Latitude");
    var geoPointMapLongitude = new Model.Dimension();
    geoPointMapLongitude.dataMember("Longitude");

    // Create the Geo Point Map dashboard item and bind it to data.
    var geoPointMapItem = new Model.GeoPointMapItem();
    geoPointMapItem.dataSource(excelDataSource.componentName());

    // ...
}

Implements

IDashboardComponent

Inherited Members

constructor

Initializes a new instance of the DataSource class.

Declaration

constructor(
    dataSourceJSON?: any,
    serializer?: DevExpress.Analytics.Utils.ModelSerializer
)

Parameters

Name Type Description
dataSourceJSON any

A JSON object used for dashboard deserialization. Do not pass this parameter directly.

serializer ModelSerializer

An object used for dashboard deserialization. Do not pass this parameter directly.

Properties

calculatedFields Property

Provides access to data source’s calculated fields.

Declaration

calculatedFields: ko.ObservableArray<DevExpress.Dashboard.Model.CalculatedField>

Property Value

Type Description
ObservableArray<CalculatedField>

An array of the CalculatedField objects that are calculated fields.

Remarks

See Web Dashboard - Creating Calculated Fields for information about calculated fields.

See Also

componentName Property

Declaration

componentName: ko.Observable<string>

Property Value

Type
Observable<string>

filter Property

Declaration

filter: ko.Observable<string>

Property Value

Type
Observable<string>

hasCalculatedFields Property

Declaration

hasCalculatedFields: boolean

Property Value

Type
boolean

hasFilter Property

Declaration

hasFilter: boolean

Property Value

Type
boolean

name Property

Declaration

name: ko.Observable<string>

Property Value

Type
Observable<string>

supportDataMembers Property

Declaration

supportDataMembers: boolean

Property Value

Type
boolean

Methods

getDisplayNamePrefix Method

Gets the display name of the current data source.

Declaration

abstract getDisplayNamePrefix(): string

Returns

Type Description
string

A string that is the display name of the current data source.

getInfo Method

For internal use.

Declaration

abstract getInfo(): DevExpress.Analytics.Utils.ISerializationInfoArray

Returns

Type Description
ISerializationInfoArray

An array of objects that provide serialization info.

getJson Method

Declaration

getJson(): any

Returns

Type
any

getUniqueNamePrefix Method

Declaration

getUniqueNamePrefix(): string

Returns

Type
string