DashboardLayoutGroup Class

Represents a layout group used to arrange layout items or other groups within a dashboard.

Namespace: DevExpress.DashboardCommon

Assembly: DevExpress.Dashboard.v18.1.Core.dll

Syntax

public class DashboardLayoutGroup :
    DashboardLayoutNode,
    IDashboardLayoutNode

The DashboardLayoutGroup class exposes the DashboardLayoutGroup.ChildNodes property that provides access to the collection of child layout groups and items that constitute the current layout group. Use the DashboardLayoutGroup.Orientation property to specify the orientation of layout items/groups within the group.

The DashboardLayoutNode.Weight property allows to specify the relative size of the layout group.

Examples

The following example demonstrates how to modify dashboard layout in code.

In this example, the DashboardViewer loads a dashboard containing three dashboard items placed vertically, one above the other. The following steps are taken to create a new layout:

  • Three DashboardLayoutItem objects are created to display the existing dashboard items. The weight parameter specifies the layout item's relative size.
  • A new DashboardLayoutGroup is created to display two dashboard items. The Orientation parameter specifies how layout items are placed within the group.
  • A root layout group is created. This group contains the previously created group and another layout item.
  • The root layout group is assigned to the LayoutRoot property.

This example also demonstrates how to swap layout items using the MoveRight(DashboardLayoutNode) method, save and restore the layout using the SaveDashboardLayout(String) and LoadDashboardLayout(String) methods.

Note

The complete sample project How to modify dashboard layout in code is available in the DevExpress Examples repository.

private void ChangeLayout(DashboardToolbarItemClickEventArgs args)
{
    Dashboard dashboard = new Dashboard();
    dashboard.LoadFromXml(@"..\..\Data\Dashboard.xml");
    dashboard.BeginUpdate();

    // Create layout items used to display dashboard items.
    DashboardLayoutItem item0 = new DashboardLayoutItem(dashboard.Items[0], 35);
    DashboardLayoutItem item1 = new DashboardLayoutItem(dashboard.Items[1], 65);
    DashboardLayoutItem item2 = new DashboardLayoutItem(dashboard.Items[2], 20);
    // Create a layout group that contains two layout items.
    DashboardLayoutGroup group1 =
        new DashboardLayoutGroup(DashboardLayoutGroupOrientation.Horizontal, 80,
            item0, item1);
    // Create a root layout group that contains the previously created group and 
    // another layout item. 
    DashboardLayoutGroup rootGroup =
        new DashboardLayoutGroup(DashboardLayoutGroupOrientation.Vertical, 1,
            group1, item2);
    // Applies the layout to the dashboard.
    dashboard.LayoutRoot = rootGroup;

    dashboard.EndUpdate();
    dashboardViewer1.Dashboard = dashboard;
}

private void RepositionItems(DashboardToolbarItemClickEventArgs args)
{
    Dashboard dashboard = dashboardViewer1.Dashboard;
    DashboardLayoutGroup rootGroup = dashboard.LayoutRoot.ChildNodes[0] as DashboardLayoutGroup;
    if ((rootGroup != null) && (rootGroup.ChildNodes.Count > 1))
        rootGroup.ChildNodes[0].MoveRight(rootGroup.ChildNodes[1]);
}

private void SaveLayoutToFile(DashboardToolbarItemClickEventArgs args)
{
    dashboardViewer1.SaveDashboardLayout("DashboardLayout.xml");
}

private void LoadLayoutFromFile(DashboardToolbarItemClickEventArgs obj)
{
    if (File.Exists("DashboardLayout.xml"))
        dashboardViewer1.LoadDashboardLayout("DashboardLayout.xml");
}

Inheritance

Object
DashboardLayoutNode
DashboardLayoutGroup

See Also