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.
- For SQL data sources, use the dashboard item’s DataDashboardItem.dataSource and DataDashboardItem.dataMember properties.
- For other data sources, set only the DataDashboardItem.dataSource property.
// 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
#Inheritance
#constructor
Initializes a new instance of the DataSource
class.
#Declaration
constructor(
dataSourceJSON?: any,
serializer?: DevExpress.Analytics.Utils.ModelSerializer
)
#Parameters
Name | Type | Description |
---|---|---|
data |
any | A JSON object used for dashboard deserialization. Do not pass this parameter directly. |
serializer | Model |
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 |
---|---|
Observable |
An array of the Calculated |
#Remarks
See Web Dashboard - Creating Calculated Fields for information about calculated fields.
#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 |
---|---|
ISerialization |
An array of objects that provide serialization info. |
#getJson Method
#Declaration
getJson(): any
#Returns
Type |
---|
any |
#getUniqueNamePrefix Method
#Declaration
getUniqueNamePrefix(): string
#Returns
Type |
---|
string |