Ticket T1006104
Visible to All Users

XAF Blazor - Singleton DetailView in DashboardView

created 4 years ago

Hello Team,

I manage to create Singleton DetailView in DashboardView with below code in edit mode,

  1. However the Save Button is missing even though I am in EditMode
  2. Please suggest if you see any necessary improvement
C#
public CompanyDashboardActionViewController() { InitializeComponent(); TargetViewType = ViewType.DashboardView; // Target required Views (via the TargetXXX properties) and create their Actions. } protected override void OnActivated() { base.OnActivated(); DashboardCustomizationController _DashboardAction = Frame.GetController<DashboardCustomizationController>(); if (_DashboardAction != null) { if (_DashboardAction.View.Id == "DashboardViewCompanySettings") { ((DashboardView)View).FindItem("CompanySettings").ControlCreated += delegate (object s, EventArgs args) { DetailView detailView = ((DashboardViewItem)s).Frame.View as DetailView; detailView.CurrentObject = detailView.ObjectSpace.GetObjects<Companies>()[0]; detailView.ViewEditMode = ViewEditMode.Edit; }; } } }

Many Thx, Bunty

Answers approved by DevExpress Support

created 4 years ago (modified 4 years ago)

Hello Bunty,

Nested frames do not have the "Save" action container with this button. You can place the "Save" action to one of the supported categories: ObjectsCreation, Link, Edit, RecordEdit, View, Reports, Export, Diagnostic, Filters, FullTextSearch. See how to do this in the following help topic: Place an Action in a Different Location.
Here is an example of how to change the "Save" action's container only in this particular nested View:

C#
using DevExpress.ExpressApp; using DevExpress.ExpressApp.Editors; using DevExpress.ExpressApp.SystemModule; using System; namespace MainDemo.Module.Blazor { public class ViewController1: ViewController<DashboardView> { ActionControlsSiteController nestedActionControlsSiteController; protected override void OnActivated() { base.OnActivated(); if (View.Id == "DashboardViewCompanySettings") { DashboardViewItem companySettings = (DashboardViewItem)View.FindItem("CompanySettings"); nestedActionControlsSiteController = companySettings.Frame.GetController<ActionControlsSiteController>(); if (nestedActionControlsSiteController != null) { nestedActionControlsSiteController.CustomizeContainerActions += ViewController1_CustomizeContainerActions; } ... } } private void ViewController1_CustomizeContainerActions(object sender, CustomizeContainerActionsEventArgs e) { if (e.Category == "Edit") { e.ContainerActions.Add(e.AllActions.Find("Save")); } } protected override void OnDeactivated() { base.OnDeactivated(); if (nestedActionControlsSiteController != null) { nestedActionControlsSiteController.CustomizeContainerActions -= ViewController1_CustomizeContainerActions; nestedActionControlsSiteController = null; } } } }
    Comments (2)

      Hi Anatol,

      Thanks for your help, it worked as expected. below is my updated code, should i split it into multiple controller for performance prospect?

      C#
      public partial class CompanyDashboardActionViewController : ViewController { public CompanyDashboardActionViewController() { InitializeComponent(); TargetViewType = ViewType.DashboardView; // Target required Views (via the TargetXXX properties) and create their Actions. } ActionControlsSiteController nestedActionControlsSiteController; protected override void OnActivated() { base.OnActivated(); DashboardCustomizationController _DashboardAction = Frame.GetController<DashboardCustomizationController>(); if (_DashboardAction != null) { // Find a Dashboard by it's ID if (_DashboardAction.View.Id == "DashboardViewCompanySettings") { // Disable OrganizeDashboard and Refresh Button on Dashboardboard View _DashboardAction.OrganizeDashboardAction.Active["OrganizeDashboard"] = false; RefreshController refreshController = _DashboardAction.Frame.GetController<RefreshController>(); if (refreshController != null) { if (refreshController.View.Id == "DashboardViewCompanySettings") { refreshController.RefreshAction.Active["Refresh"] = false; } } // Find CompanySettings DetailView, Set first record, Set in Edit Mode ((DashboardView)View).FindItem("CompanySettings").ControlCreated += delegate (object s, EventArgs args) { DetailView detailView = ((DashboardViewItem)s).Frame.View as DetailView; detailView.CurrentObject = detailView.ObjectSpace.GetObjects<Companies>()[0]; detailView.ViewEditMode = ViewEditMode.Edit; }; // Above DetailsView in Edit mode Nested frames do not have the "Save" action container with this button. // To place the "Save" action button to one of the supported categories: ObjectsCreation, Link, Edit, RecordEdit, // View, Reports, Export, Diagnostic, Filters, FullTextSearch DashboardViewItem companySettings = (DashboardViewItem)_DashboardAction.View.FindItem("CompanySettings"); nestedActionControlsSiteController = companySettings.Frame.GetController<ActionControlsSiteController>(); if (nestedActionControlsSiteController != null) { nestedActionControlsSiteController.CustomizeContainerActions += ViewController1_CustomizeContainerActions; } } } } private void ViewController1_CustomizeContainerActions(object sender, CustomizeContainerActionsEventArgs e) { if (e.Category == "Edit") { e.ContainerActions.Add(e.AllActions.Find("Save")); } } protected override void OnViewControlsCreated() { base.OnViewControlsCreated(); // Access and customize the target View control. } protected override void OnDeactivated() { // Unsubscribe from previously subscribed events and release other references and resources. base.OnDeactivated(); if (nestedActionControlsSiteController != null) { nestedActionControlsSiteController.CustomizeContainerActions -= ViewController1_CustomizeContainerActions; nestedActionControlsSiteController = null; } } }

      Another issue with multiple ListViews in one Dashboard as Tabbed view is, after editing or adding a new record, the view automatically set to first Dashboard Tab instead of returning to original Tab where Add or Edit button was clicked, any idea why does this happen and how can I fix it?

      Many Thx, Bunty

      Anatol (DevExpress) 4 years ago

        Hello Bunty,

        should i split it into multiple controller for performance prospect?

        This is not necessary - this is a matter of your convenience and code style.

        I created a separate ticket for your second question: A DashboardView's layout tab is reset after returning from another View. I will answer you there shortly.

        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.