Example T994664
Visible to All Users

BI Dashboard for ASP.NET Core - How to obtain underlying data for the specified dashboard item

The example shows how to get underlying data for the specified dashboard item. Underlying data is displayed in the dxDataGrid widget placed next to the Web Dashboard.

The example uses the ViewerApiExtension.requestUnderlyingData method and passes the component name of the dashboard item and specific parameters to request data.

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

Example Code

AspNetCoreDashboard_UnderlyingData/wwwroot/js/UnderlyingData.js
JavaScript
function onDashboardEndUpdate(args) { var dashboardControl = args.component; // Gets client data displayed in the Card dashboard item. var viewerApiExtension = dashboardControl.findExtension('viewerApi'); var clientData = viewerApiExtension.getItemData('cardDashboardItem1'); // Creates an array of data members used to obtain underlying data. var availableDataMembers = clientData.getDataMembers(); var specificDataMembers = availableDataMembers.filter(function (dataMember) { return ['Sales Person', 'Extended Price', 'OrderDate'].indexOf(dataMember) !== -1; }); // Gets an axis point corresponding to a specific employee. var allSalesPersons = clientData.getAxis("Default").getPoints(); var specificSalesPerson = allSalesPersons.find(function (person) { return person.getValue() === "Andrew Fuller"; }); // Gets an axis point corresponding to a specific month. var allDates = clientData.getAxis("Sparkline").getPoints(); var specificDate = allDates.find(function (date) { return date.getValue().toDateString() === (new Date(2016, 4, 1)).toDateString(); }); // Creates an object passed to the RequestUnderlyingData method. var requestParameters = { DataMembers: specificDataMembers, AxisPoints: [specificSalesPerson, specificDate] }; var underlyingData = []; // Calls the RequestUnderlyingData method for the Card dashboard item with the specified parameters. viewerApiExtension.requestUnderlyingData('cardDashboardItem1', requestParameters, function (data) { dataMembers = data.getDataMembers(); for (var i = 0; i < data.getRowCount(); i++) { var dataTableRow = {}; $.each(dataMembers, function (_, dataMember) { dataTableRow[dataMember] = data.getRowValue(i, dataMember); }); underlyingData.push(dataTableRow); } $("#detailGrid").dxDataGrid({ height: 850, scrolling: { mode: 'virtual' }, dataSource: underlyingData }); }); }
AspNetCoreDashboard_UnderlyingData/Pages/_Layout.cshtml
Razor
<!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" /> </head> <body> @RenderBody() <script src="js/site.min.js"></script> <script src="js/UnderlyingData.js"></script> </body> </html>
AspNetCoreDashboard_UnderlyingData/Pages/Index.cshtml
Razor
@page <div id="detailGrid" style="position:absolute; left:800px; right:0; top:0; bottom:0;"></div> <div style="position: absolute; left: 0; top: 0; right: 0; bottom: 0;"> @(Html.DevExpress().Dashboard("dashboardControl1") .ControllerName("DefaultDashboard") .Width("800px") .Height("100%") .WorkingMode(DevExpress.DashboardWeb.WorkingMode.ViewerOnly) .OnDashboardEndUpdate("onDashboardEndUpdate") ) </div>

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.