dashboard-js-devexpress-dot-dashboard-e1164b97.md
A custom dashboard item.
export class CustomItemViewer extends baseItem
A custom item is a separate JavaScript extension that is integrated into the Web Dashboard and provides standard item functionality such as data shaping operations, interactivity, export, etc.
To learn more about custom items, go to Create a Custom Item for the Web Dashboard.
Initializes a new instance of the CustomItemViewer class.
constructor(
model: DevExpress.Dashboard.Model.CustomItem,
container: DevExpress.Dashboard.DxElement,
options: any
)
| Name | Type | Description |
|---|---|---|
| model | CustomItem |
A custom item model.
| | container | DxElement |
A container where the item content is rendered. It is an HTML Element or a jQuery Element when you use jQuery.
| | options | any |
Custom item settings.
|
Indicates whether end-users can drill down by clicking on the custom item’s UI object. This object should be associated with a specified data row.
canDrillDown: (row?: DevExpress.Dashboard.Model.ICustomDataRow) => boolean
| Type |
|---|
| (row?: ICustomDataRow) => boolean |
Indicates whether end-users can filter data by clicking on the custom item’s UI object. This object should be associated with a specified data row.
canMasterFilter: (row?: DevExpress.Dashboard.Model.ICustomDataRow) => boolean
| Type |
|---|
| (row?: ICustomDataRow) => boolean |
Allows you to display detail data for the custom item’s UI object. This object should be associated with a specified data row.
drillDown: (row: DevExpress.Dashboard.Model.ICustomDataRow) => boolean
| Type |
|---|
| (row: ICustomDataRow) => boolean |
Iterates data rows for a custom item.
iterateData: (action: (item: DevExpress.Dashboard.Model.ICustomDataRow) => void) => void
| Type | Description |
|---|---|
| (action: (item: ICustomDataRow) => void) => void |
A function that is executed for the specified data row.
|
Use the ICustomDataRow.getDisplayText and ICustomDataRow.getValue properties to get a value and a display name of the data row, respectively.
See the Simple Table custom dashboard item code to find an example of the iterateData implementation:
View Example: ASP.NET CoreView Example: AngularView Example: React
Allows you to set a master filter for the custom item’s UI object. This object should be associated with a specified data row.
setMasterFilter: (row: DevExpress.Dashboard.Model.ICustomDataRow) => boolean
| Type | Description |
|---|---|
| (row: ICustomDataRow) => boolean |
A function that is executed when you pass a custom data row.
|
The following code is a snippet from the Funnel D3 item’s source code and shows the interactivity implementation:
_onClick(e) {
if (!this._hasArguments() || !e.label)
return;
var row = e.label.raw.data;
if (this.canDrillDown(row))
this.drillDown(row);
else if (this.canMasterFilter(row)) {
this.setMasterFilter(row);
this._update();
}
}
Pass null in the setMasterFilter method to clear the master filter:
this.setMasterFilter(null);
You can find and download the full example on GitHub:
View Example: ASP.NET CoreView Example: AngularView Example: React
Specifies whether end-users can export a custom item as a single dashboard item.
allowExportSingleItem(): boolean
| Type | Description |
|---|---|
| boolean |
true , if end-users can export a custom item as a single dashboard item; otherwise, false.
|
Use the getExportInfo method to provide the export result during exporting.
Allows you to clear a selection in the custom item.
clearSelection(): void
Important
You need to override this method to reset the viewer selection.
Returns the item content height (without header).
contentHeight(): number
| Type | Description |
|---|---|
| number |
An integer value that is the item content height, not including the header pane height.
|
Returns the item content width.
contentWidth(): number
| Type | Description |
|---|---|
| number |
An integer value that is the item content width.
|
Disposes of all resources associated with this CustomItemViewer.
dispose(): void
Returns an array of objects that allows you to get information about the binding value.
getBindingValue(
propertyName: string,
index?: number
): Array<DevExpress.Dashboard.Model.ICustomItemBindingValue>
| Name | Type | Description |
|---|---|---|
| propertyName | string |
A string value that is the name of the binding property from the meta data.
| | index | number |
The binding property index. Use this parameter if the current data binding is an array.
|
| Type | Description |
|---|---|
| ICustomItemBindingValue[] |
An array of data binding values.
|
Returns an object that is used as an export result.
getExportInfo(): CustomItemExportInfo
| Type | Description |
|---|---|
| CustomItemExportInfo |
A CustomItemExportInfo object that contain an image in the ASCII format using the Base64 scheme.
|
Override this method and provide an object containing the image field. Encode the image in the ASCII format using the Base64 scheme to display a custom item in the exported document.
Note that getExportInfo is a synchronous method and it cannot be used with libraries exporting data asynchronously. You can export your custom item to an image when the custom item rendering is updated and caches the resulting image. After that return the cached image in the getExportInfo method.
See the getExportInfo method in the FunnelD3 custom dashboard item code to find an export implementation example:
View Example: ASP.NET CoreView Example: AngularView Example: React
For internal use.
getInfo(): any
| Type |
|---|
| any |
getMasterFilterMode(): string
| Type |
|---|
| string |
Returns an array of objects that allows you to get information about the custom property value.
getPropertyValue(
propertyName: string
): DevExpress.Dashboard.Model.CustomPropertyValueType
| Name | Type | Description |
|---|---|---|
| propertyName | string |
A string value that is the name of the custom property from the meta data.
|
| Type | Description |
|---|---|
| CustomPropertyValueType |
An array of custom properties.
|
initializeData(
newOptions: any
): void
| Name | Type |
|---|---|
| newOptions | any |
Specifies whether the custom item’s UI object is selected. This object should be associated with a specified data row.
isSelected(
row: DevExpress.Dashboard.Model.ICustomDataRow
): boolean
| Name | Type | Description |
|---|---|---|
| row | ICustomDataRow |
A specified data row.
|
| Type | Description |
|---|---|
| boolean |
true if the custom item’s UI object is selected; otherwise, false.
|
Renders the custom dashboard item.
renderContent(
element: DevExpress.Dashboard.DxElement,
changeExisting: boolean,
afterRenderCallback?: any
): void
| Name | Type | Description |
|---|---|---|
| element | DxElement |
A container where the item content is rendered. It is an HTML Element or a jQuery Element when you use jQuery.
| | changeExisting | boolean |
true , to update only a custom item’s changed content; false , to render item content from scratch.
| | afterRenderCallback | any |
The current parameter is for internal use.
|
When you interact with a custom item and add changes to it, you need to update the custom item view. The renderContent method is called while item content is rendering. Override this method and add custom logic to display the item content. Use the changeExisting parameter that indicates whether to update a custom item’s changed content or render it from scratch.
renderContent method is not called) until you add at least one measure or dimension in the Web Dashboard’s UI.Note
Do not set IDs for DOM elements in the renderContent method call. When the custom item is maximized, its viewer part (CustomItemViewer is copied with all its elements and the element ID will not be unique on the page.
Sets a selection in the custom item.
setSelection(
values: Array<Array<any>>
): void
| Name | Type |
|---|---|
| values | any[][] |
Override this method to set the Master Filtering using API.
Sets the content size.
setSize(
width: number,
height: number
): void
| Name | Type | Description |
|---|---|---|
| width | number |
An integer value that is the pane width, including header.
| | height | number |
An integer value that is the pane height, including header.
|
Important
You need to override this method to update the content size (for instance, when a dashboard layout is changed). The method override’s code should call the base setSize method.
Allows you to react on and subscribe to property changes.
subscribe(
propertyName: string,
callback: (newValue: any) => void
): any
| Name | Type | Description |
|---|---|---|
| propertyName | string |
A string value that is a name of the property from the meta data.
| | callback | (newValue: any) => void | |
| Type |
|---|
| any |