Current filter:
                                You should refresh the page.
                                  • Can you guys add an option to collapse the layout groups that are used in xaf applications?

                                1 Solution

                                Creation Date Importance Sort by

                                Hi Charles,

                                Thanks for the suggestion. We will take it into account. For now, it's possible to implement this feature yourself:

                                ASP.NET:


                                15.2+
                                The new XAF web UI provides a built-in solution for this task. You can enable it for required layout groups in the Model Editor via the new IsCollapsibleCardGroup option at the Views | <DetailView> | Layout  level.

                                For older versions or fully custom-tailored Web implementations when the standard option is not suitable
                                To accomplish this task, you need to create a custom LayoutManager and custom LayoutItemTemplate, LayoutGroupTemplate or TabbedGroupTemplate templates as demonstrated in the FeatureCenter demo (%Public%\Documents\DevExpress Demos 1X.X\Components\eXpressApp Framework\FeatureCenter\CS\FeatureCenter.Module.Web\Layout\). For instance, you can inherit from the existing WebLayoutManager class and override the CreateLayoutGroupTemplate method to return a custom template for layout groups. The original method returns a LayoutGroupTemplate instance that creates a simple HTML table for the group header and puts nested layout items just below it in the same container. You can create a LayoutGroupTemplate descendant and override the LayoutContentControls method to create a collapsible group with the help of a script or custom control. In the simplest case, it is possible to use our ASPxNavBar control our ASPxRoundPanel with its ShowCollapseButton = True.


                                WinForms:

                                You can access the LayoutControl and set its LayoutControlGroup.ExpandXXX properties either in a ViewController or a custom WinLayoutManager descendant. To save and control the expandable state of required layout groups via the Model Editor, extend the IModelWinLayoutGroup interface with custom options as described in the eXpressApp Framework > Task-Based Help > How to: Extend the Application Model help topic. Handle the View.ModelSaved event to write the expanded state from the control to the Application Model. Refer to the Model.DesignedDiffs.xafml  and ExpandableLayoutGroupViewController.cs files under the WinForms module project in the dxSampleS135134_WinForms_C#.zip  archive for more details:

                                [C#]
                                using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using DevExpress.ExpressApp; using DevExpress.ExpressApp.Model; using DevExpress.ExpressApp.Win.Layout; using DevExpress.ExpressApp.Win.SystemModule; using DevExpress.Utils; using DevExpress.XtraLayout; namespace YourSolutionName.Module.Win.Controllers { public partial class ExpandableLayoutGroupViewController : ViewController<DetailView>, IModelExtender { Dictionary<string, IModelWinLayoutGroupExtender> itemToWinModelLayoutGroupExtenderMap = new Dictionary<string, IModelWinLayoutGroupExtender>(); WinLayoutManager winLayoutManager = null; protected override void OnActivated() { base.OnActivated(); winLayoutManager = View.LayoutManager as WinLayoutManager; if(winLayoutManager != null) { winLayoutManager.ItemCreated += ExpandableLayoutGroupViewControllercs_ItemCreated; if(winLayoutManager.Container != null) { winLayoutManager.Container.HandleCreated += Container_HandleCreated; } View.ModelSaved += View_ModelSaved; } } void Container_HandleCreated(object sender, EventArgs e) { LayoutControl lc = ((LayoutControl)sender); lc.BeginUpdate(); foreach(BaseLayoutItem item in lc.Items) { if((item is LayoutControlGroup) && itemToWinModelLayoutGroupExtenderMap.ContainsKey(item.Name)) { ((LayoutGroup)item).Expanded = itemToWinModelLayoutGroupExtenderMap[item.Name].Expanded; ((LayoutGroup)item).HeaderButtonsLocation = itemToWinModelLayoutGroupExtenderMap[item.Name].HeaderButtonsLocation; ((LayoutGroup)item).ExpandButtonVisible = true; ((LayoutGroup)item).ExpandOnDoubleClick = true; } } lc.EndUpdate(); } void ExpandableLayoutGroupViewControllercs_ItemCreated(object sender, ItemCreatedEventArgs e) { if(e.ModelLayoutElement is IModelWinLayoutGroup) { IModelWinLayoutGroupExtender modelLayoutGroupExtender = (IModelWinLayoutGroupExtender)e.ModelLayoutElement; if((modelLayoutGroupExtender).Expandable) { itemToWinModelLayoutGroupExtenderMap.Add(e.Item.Name, (IModelWinLayoutGroupExtender)e.ModelLayoutElement); } } } void View_ModelSaved(object sender, EventArgs e) { foreach(BaseLayoutItem item in winLayoutManager.Container.Items) { if((item is LayoutControlGroup) && itemToWinModelLayoutGroupExtenderMap.ContainsKey(item.Name)) { itemToWinModelLayoutGroupExtenderMap[item.Name].Expanded = ((LayoutGroup)item).Expanded; } } } protected override void OnDeactivated() { if(winLayoutManager != null) { winLayoutManager.ItemCreated -= ExpandableLayoutGroupViewControllercs_ItemCreated; if(winLayoutManager.Container != null) { winLayoutManager.Container.HandleCreated -= Container_HandleCreated; winLayoutManager = null; } View.ModelSaved -= View_ModelSaved; } itemToWinModelLayoutGroupExtenderMap.Clear(); base.OnDeactivated(); } public void ExtendModelInterfaces(ModelInterfaceExtenders extenders) { extenders.Add<IModelWinLayoutGroup, IModelWinLayoutGroupExtender>(); } } public interface IModelWinLayoutGroupExtender { [DefaultValue(true)] bool Expanded { get; set; } [DefaultValue(true)] bool Expandable { get; set; } [DefaultValue(GroupElementLocation.Default)] GroupElementLocation HeaderButtonsLocation { get; set; } } }




                                 

                                • Charles Kirby 08.16.2010

                                  I was able to display the expand button by using the steps in the other post. However, the changes are obviously not persisted with the default integral settings. I would still like to see this feature as an integral part of xaf at some point. Then developers could enable/disable the expand button from the model editor and at runtime, collapsed states of groups could automatically be persisted with the rest of the settings.

                                • Dennis (DevExpress Support) 02.24.2016
                                  @All:
                                  Starting with v15.2, the new XAF web UI provides a built-in solution for this task. You can enable it for required layout groups in the Model Editor via the new IsCollapsibleCardGroup option at the Views | <DetailView> | Layout  level. I have provided screenshots and more info on this in my blog at http://dennisgaravsky.blogspot.com/2016/02/collapsible-layout-groups-in-new-xaf.html

                                • Pawel Botwina 02.24.2016
                                  Hello,

                                  I have tested this functionality. Currently it lacks ability to set initial state (collapsed or not collapsed) and group caption should be clickable.
                                • Dennis (DevExpress Support) 02.24.2016
                                  Thanks for your comments, Pawel!