The requested page is not available for the requested platform. You are viewing the content for Default platform.

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());

    // ...
}

constructor

Initializes a new instance of the DataSource class.

Declaration

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

Optional Parameters

Name Type Default Description
dataSourceJSON any null
serializer DxDesigner.Analytics.Utils.ModelSerializer null

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

Properties

calculatedFields Property

Provides access to data source's calculated fields.

Declaration

calculatedFields: ko.ObservableArray<CalculatedField>

Property Value

Type Description
ko.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 Description
ko.Observable<string>

hasCalculatedFields Property

Declaration

hasCalculatedFields: boolean

Property Value

Type Description
boolean

name Property

Declaration

name: ko.Observable<string>

Property Value

Type Description
ko.Observable<string>

supportDataMembers Property

Declaration

supportDataMembers: boolean

Property Value

Type Description
boolean

Methods

getDisplayNamePrefix Method

Declaration

abstract getDisplayNamePrefix(): string

Returns

Type Description
string

getInfo Method

For internal use.

Declaration

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

Returns

Type Description
DxDesigner.Analytics.Utils.ISerializationInfoArray

 

getJson Method

Declaration

getJson(): any

Returns

Type Description
any

getUniqueNamePrefix Method

Declaration

getUniqueNamePrefix(): string

Returns

Type Description
string