DashboardViewerSettings Class
OBSOLETE
The DashboardViewer extension is obsolete. Use the Dashboard extension instead. See https://go.devexpress.com/migration-to-web-dashboard-control.aspx for details.
Namespace: DevExpress.DashboardWeb.Mvc
Assembly: DevExpress.Dashboard.v18.2.Web.Mvc5.dll
Declaration
[Obsolete("The DashboardViewer extension is obsolete. Use the Dashboard extension instead. See https://go.devexpress.com/migration-to-web-dashboard-control.aspx for details.")]
public class DashboardViewerSettings :
DashboardControlSettingsBase
<Obsolete("The DashboardViewer extension is obsolete. Use the Dashboard extension instead. See https://go.devexpress.com/migration-to-web-dashboard-control.aspx for details.")>
Public Class DashboardViewerSettings
Inherits DashboardControlSettingsBase
Example
The following example demonstrates how to load a dashboard to an MVC Dashboard Viewer at runtime.
@using(Html.BeginForm()) {
@Html.Action("DashboardViewerPartial")
}
@model DevExpress.DashboardWeb.Mvc.DashboardSourceModel
@Html.DevExpress().DashboardViewer(settings => {
settings.Name = "DashboardViewer";
settings.CallbackRouteValues = new { Controller = "Home", Action = "DashboardViewerPartial" };
settings.ExportRouteValues = new { Controller = "Home", Action = "DashboardViewerPartialExport" };
settings.FullscreenMode = true;
}).BindToSource(Model).GetHtml()
Imports System.Web.Mvc
Imports DevExpress.DashboardWeb.Mvc
Imports DevExpress.DataAccess.ConnectionParameters
Imports System.IO
Namespace MVCLoadingDashboard.Controllers
Public Class HomeController
Inherits Controller
Public Function Index() As ActionResult
Return View()
End Function
<ValidateInput(False)> _
Public Function DashboardViewerPartial() As ActionResult
Return PartialView("_DashboardViewerPartial", DashboardViewerSettings.Model)
End Function
Public Function DashboardViewerPartialExport() As FileStreamResult
Return DashboardViewerExtension.Export("DashboardViewer", DashboardViewerSettings.Model)
End Function
End Class
Friend Class DashboardViewerSettings
Public Shared ReadOnly Property Model() As DashboardSourceModel
Get
Dim model_Renamed As New DashboardSourceModel()
model_Renamed.DashboardId = "SalesDashboard"
model_Renamed.DashboardLoading = Sub(sender, e)
' Checks the identifier of the required dashboard.
If e.DashboardId = "SalesDashboard" Then
' Writes the dashboard XML definition from a file to a string.
Dim dashboardDefinition As String =
File.ReadAllText(System.Web.Hosting.HostingEnvironment.MapPath("~\App_Data\SalesDashboard.xml"))
' Specifies the dashboard XML definition.
e.DashboardXml = dashboardDefinition
End If
End Sub
model_Renamed.ConfigureDataConnection = Sub(sender, e)
If e.DataSourceName = "SQL Data Source 1" Then
' Gets connection parameters used to establish a connection to the database.
Dim parameters As Access97ConnectionParameters =
CType(e.ConnectionParameters, Access97ConnectionParameters)
Dim databasePath As String = System.Web.Hosting.HostingEnvironment.MapPath("~\App_Data\nwind.mdb")
' Specifies the path to a database file.
parameters.FileName = databasePath
End If
End Sub
Return model_Renamed
End Get
End Property
End Class
End Namespace
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
@Html.DevExpress().GetStyleSheets(
new StyleSheet { ExtensionSuite = ExtensionSuite.DashboardViewer }
)
@Html.DevExpress().GetScripts(
new Script { ExtensionSuite = ExtensionSuite.DashboardViewer }
)
</head>
<body>
<div class="content">
@RenderBody()
</div>
</body>
</html>
@model DevExpress.DashboardWeb.Mvc.DashboardSourceModel
@Html.DevExpress().DashboardViewer(settings => {
settings.Name = "DashboardViewer";
settings.CallbackRouteValues = new { Controller = "Home", Action = "DashboardViewerPartial" };
settings.ExportRouteValues = new { Controller = "Home", Action = "DashboardViewerPartialExport" };
settings.FullscreenMode = true;
}).BindToSource(Model).GetHtml()
using System.Web.Mvc;
using DevExpress.DashboardWeb.Mvc;
using DevExpress.DataAccess.ConnectionParameters;
using System.IO;
namespace MVCLoadingDashboard.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
[ValidateInput(false)]
public ActionResult DashboardViewerPartial() {
return PartialView("_DashboardViewerPartial", DashboardViewerSettings.Model);
}
public FileStreamResult DashboardViewerPartialExport() {
return DashboardViewerExtension.Export("DashboardViewer", DashboardViewerSettings.Model);
}
}
class DashboardViewerSettings {
public static DashboardSourceModel Model {
get {
DashboardSourceModel model = new DashboardSourceModel();
model.DashboardId = "SalesDashboard";
model.DashboardLoading = (sender, e) => {
// Checks the identifier of the required dashboard.
if (e.DashboardId == "SalesDashboard") {
// Writes the dashboard XML definition from a file to a string.
string dashboardDefinition = File.ReadAllText(System.Web.Hosting.
HostingEnvironment.MapPath(@"~\App_Data\SalesDashboard.xml"));
// Specifies the dashboard XML definition.
e.DashboardXml = dashboardDefinition;
}
};
model.ConfigureDataConnection = (sender, e) => {
if (e.DataSourceName == "SQL Data Source 1") {
// Gets connection parameters used to establish a connection to the database.
Access97ConnectionParameters parameters =
(Access97ConnectionParameters)e.ConnectionParameters;
string databasePath = System.Web.Hosting.
HostingEnvironment.MapPath(@"~\App_Data\nwind.mdb");
// Specifies the path to a database file.
parameters.FileName = databasePath;
}
};
return model;
}
}
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
@Html.DevExpress().GetStyleSheets(
new StyleSheet { ExtensionSuite = ExtensionSuite.DashboardViewer }
)
@Html.DevExpress().GetScripts(
new Script { ExtensionSuite = ExtensionSuite.DashboardViewer }
)
</head>
<body>
<div class="content">
@RenderBody()
</div>
</body>
</html>
@using(Html.BeginForm()) {
@Html.Action("DashboardViewerPartial")
}
Inheritance
ObjectSettingsBaseDevExpress.DashboardWeb.Mvc.DashboardControlSettingsBaseDashboardViewerSettings
See Also