dashboard-401090-web-dashboard-integrate-dashboard-component-aspnet-core-dashboard-control-access-to-underlying-widgets.md
Tip
This topic shows the ASP.NET Core specifics. The main widget customization concepts are described in the following article: Access to Underlying Widgets in DashboardControl.
Most dashboard items use DevExtreme UI widgets to visualize data. Use the DashboardControl‘s API to access these widgets and customize their settings. In ASP.NET Core, you need to subscribe to the ViewerApiExtension events that allow you to access underlying UI/Data Visualization widgets. For this, use the DashboardBuilder.OnBeforeRender event handler, call the ViewerApiExtension.on method and pass the event name as the method’s parameter.
Several dashboard items use built-in components instead of DevExtreme-based UI widgets.
Layout items do not have underlying components.
See the table in the following topic for information about dashboard items and their underlying components: Access to Underlying Widgets in DashboardControl.
The example shows how to customize options of underlying widgets. Handle the onItemWidgetOptionsPrepared event to do the following:
@page
<div style="position: absolute; left: 0; top: 0; right: 0; bottom: 0;">
@(Html.DevExpress().Dashboard("dashboardControl1")
.Width("100%")
.Height("100%")
.OnBeforeRender("onBeforeRender")
)
</div>
function onBeforeRender(s, e) {
var viewerApiExtension = s.findExtension('viewerApi');
if (viewerApiExtension)
viewerApiExtension.on('itemWidgetOptionsPrepared', customizeWidgetOptions);
}
function customizeWidgetOptions(e) {
if (e.dashboardItem instanceof DevExpress.Dashboard.Model.GridItem) {
e.options.hoverStateEnabled = true
};
if (e.dashboardItem instanceof DevExpress.Dashboard.Model.ChartItem) {
e.options.tooltip = {
enabled: false
};
e.options.animation = {
enabled: true,
duration: 1000
};
e.options.onArgumentAxisClick = function (info) {
info.component.getAllSeries()[0].getPointsByArg(info.argument)[0].showTooltip()
}
};
if (e.dashboardItem instanceof DevExpress.Dashboard.Model.PieItem) {
e.options.legend = {
visible: true,
border: {
visible: true
}
};
e.options.animation = {
enabled: true,
duration: 1000
};
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Dashboard Web Application</title>
<link href="css/site.min.css" rel="stylesheet" />
<script src="js/widgetsCustomization.js"></script>
</head>
<body>
@RenderBody()
<script src="js/site.min.js"></script>
</body>
</html>