Ticket Q582278
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

How do I provide the capability to collapse or expand layout groups and persist their state?

How to save the expandable state of LayoutGroup based on example in Q101774

created 11 years ago

Hello,

I implement Expandable Groups described in Q101774 , but i have problem to save the state of it ?
Can you please show me on example .

Thanks
JeyKey

Answers approved by DevExpress Support

created 11 years ago (modified 8 years ago)

UPDATED:
I've attached a complete WinForms sample to the How do I provide the capability to collapse or expand layout groups and persist their state? ticket (see its WinForms section for the main implementation steps). I hope you find this information helpful.
==========
Hello JeyKey,
I am afraid we do not have a ready example or guideline for this task. Technically, you can store the information about the expanded state in the application model. The state should be linked to the group's identifier or text.
To store some custom settings in the application model, create a custom model extension as described in the Extend and Customize the Application Model in Code article. Of course, you can use any other store for your custom settings here.

    Other Answers

    created 11 years ago (modified 11 years ago)

    Hello Denis,

    thanks for advice .
    Here is the solution .

    C#
    // ModelExtender.cs public interface IModelLayoutGroupExtender { [DefaultValue(true)] bool Expanded { get; set; } [DefaultValue(false)] bool Expandable { get; set; } [DefaultValue(GroupElementLocation.Default)] GroupElementLocation ExpandButtonLocation { get; set; } } // Module.cs public override void ExtendModelInterfaces(ModelInterfaceExtenders extenders) { base.ExtendModelInterfaces(extenders); extenders.Add<IModelLayoutGroup, IModelLayoutGroupExtender>(); } //ExpandableLayoutGroupViewController.cs public partial class ExpandableLayoutGroupViewController : ViewController<DetailView> { Dictionary<string, IModelLayoutGroupExtender> layoutGroups = new Dictionary<string, IModelLayoutGroupExtender>(); public ExpandableLayoutGroupViewController() { InitializeComponent(); RegisterActions(components); // Target required Views (via the TargetXXX properties) and create their Actions. } protected override void OnViewControlsCreated() { base.OnViewControlsCreated(); foreach (BaseLayoutItem item in ((LayoutControl)View.Control).Items) { if (item is LayoutControlGroup && layoutGroups.ContainsKey(item.Name)) { ((LayoutGroup)item).Expanded = layoutGroups[item.Name].Expanded; ((LayoutGroup)item).ExpandButtonLocation = layoutGroups[item.Name].ExpandButtonLocation; ((LayoutGroup)item).ExpandButtonVisible = true; ((LayoutGroup)item).ExpandOnDoubleClick = true; } } } protected override void OnActivated() { base.OnActivated(); View.ModelSaved += View_ModelSaved; ((WinLayoutManager)(View.LayoutManager)).ItemCreated += ExpandableLayoutGroupViewControllercs_ItemCreated; } void ExpandableLayoutGroupViewControllercs_ItemCreated(object sender, ItemCreatedEventArgs e) { if (e.ModelLayoutElement is IModelLayoutGroup) { IModelLayoutGroup lg = e.ModelLayoutElement as IModelLayoutGroup; if ((lg as IModelLayoutGroupExtender).Expandable) layoutGroups.Add(e.Item.Name, (IModelLayoutGroupExtender)e.ModelLayoutElement); } } protected override void OnDeactivated() { ((WinLayoutManager)(View.LayoutManager)).ItemCreated -= ExpandableLayoutGroupViewControllercs_ItemCreated; View.ModelSaved -= View_ModelSaved; base.OnDeactivated(); } void View_ModelSaved(object sender, EventArgs e) { foreach (BaseLayoutItem item in ((LayoutControl)View.Control).Items) { if (item is LayoutControlGroup && layoutGroups.ContainsKey(item.Name)) { layoutGroups[item.Name].Expanded = ((LayoutGroup)item).Expanded; } } } }

    JeyKey

      Comments (1)
      Dennis Garavsky (DevExpress) 11 years ago

        Thank you for sharing your solution with the XAF community.

        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.