Skip to main content
A newer version of this page is available. .

How to: Customize a Layout of the Specified Group

  • 3 minutes to read

Important

This documentation applies to v16.2. Starting with v17.1, the ASPxDashboardViewer control is in maintenance mode. In v19.1, the new Web Dashboard Control replaces the old Web Dashboard Viewer. This means that the Web Dashboard Viewer will not be included in our installation packages. See our blog post for more information.

Refer to the following KB articles to learn how to migrate to ASPxDashboard / ASP.NET MVC Dashboard:

The following example demonstrates how to change a layout of the specified group in code.

In this example, the ASPxDashboardViewer loads an existing dashboard with the predefined layout from an XML file. The bottom group contains three dashboard items that are placed horizontally side-by-side.

The following steps are performed to customize a group layout:

Imports System
Imports DevExpress.DashboardWeb
Imports DevExpress.DataAccess.ConnectionParameters
Imports DevExpress.DashboardCommon

Namespace Dashboard_UpdateGroupLayout
    Partial Public Class WebForm1
        Inherits System.Web.UI.Page

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        End Sub

        Protected Sub ASPxDashboardViewer1_DashboardLoaded(ByVal sender As Object, _
                                           ByVal e As DashboardLoadedWebEventArgs)
            Dim dashboard As Dashboard = e.Dashboard
            Dim root As DashboardLayoutGroup = dashboard.LayoutRoot
            Dim bottomLayoutGroup As DashboardLayoutGroup = root.FindRecursive(e.Dashboard.Groups(1))

            Dim comboBox As DashboardItem = CType(dashboard.Items("comboBoxDashboardItem1"),  _
                ComboBoxDashboardItem)
            Dim listBox As DashboardItem = CType(dashboard.Items("listBoxDashboardItem1"),  _
                ListBoxDashboardItem)
            Dim chart As DashboardItem = CType(dashboard.Items("chartDashboardItem2"),  _
                ChartDashboardItem)

            Dim comboBoxLayoutItem As DashboardLayoutItem = root.FindRecursive(comboBox)
            comboBoxLayoutItem.Weight = 10
            Dim listBoxLayoutItem As DashboardLayoutItem = root.FindRecursive(listBox)
            listBoxLayoutItem.Weight = 90
            Dim chartLayoutItem As DashboardLayoutItem = root.FindRecursive(chart)
            chartLayoutItem.Weight = 76

            bottomLayoutGroup.ChildNodes.RemoveRange(comboBoxLayoutItem, _
                                                     listBoxLayoutItem, _
                                                     chartLayoutItem)
            Dim childGroup1 As New DashboardLayoutGroup(DashboardLayoutGroupOrientation.Vertical, 24, _
                                                        comboBoxLayoutItem, listBoxLayoutItem)
            bottomLayoutGroup.ChildNodes.AddRange(childGroup1, chartLayoutItem)
        End Sub

        Protected Sub ASPxDashboardViewer1_ConfigureDataConnection(ByVal sender As Object, _
                                           ByVal e As ConfigureDataConnectionWebEventArgs)
            If e.ConnectionName = "WebsiteStatisticsDataConnection" Then
                Dim parameters As XmlFileConnectionParameters = CType(e.ConnectionParameters,  _
                    XmlFileConnectionParameters)
                Dim databasePath As String = Server.MapPath("App_Data/WebsiteStatisticsData.xml")
                parameters.FileName = databasePath
            End If
        End Sub
    End Class
End Namespace
See Also