Bug Report Q497985
Visible to All Users

Usability - A drop-down control is unexpectedly used for SingleChoiceAction with a single visible sub-item

created 12 years ago

Hello,

I Was wondering if it's possible to change the style of a NewObjectAction (http://documentation.devexpress.com/#xaf/DevExpressExpressAppSystemModuleNewObjectViewController_NewObjectActiontopic) so it's not in a combobox but just as a simple action (button). The object that needs to be add will be the CurrentObject of theView.

Is that possible?

Cheers.

Answers approved by DevExpress Support

created 7 years ago (modified 5 years ago)

We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

Additional information:

This usability improvement affects SingleChoiceAction with ShowItemsOnClick = False and ItemType = ItemIsOperation   and should improve UX for the majority of our users.

17.2.5 and older versions

17.2.6+
**

Notice that we've replaced a dropdown/triangle glyph with a simple button. We and many our customers believe that this visual change is still not breaking (and thus is acceptable for a minor version), and it all is more logical than it was before. Before, when ShowItemsOnClick = False, you could still press the SingleChoiceAction's button blindly, i.e., without expanding its items using the triangle glyph. To help you avoid mistakes, the button is now displayed in the ChoiceActionItem's tooltip. You can also control the default Action item behavior using the DefaultItemMode property.

If you do not like the new behavior, you can always set ShowItemsOnClick = True in the Model Editor or in code for your SingleChoiceAction.

    created 12 years ago (modified 7 years ago)

    By default, XAF allows defining whether a SingleChoiceAction click should show a dropdown or execute an action item immediately using the ShowItemsOnClick and DefaultItemMode  properties. You can easily change these properties based on the number of the New action items. However, a triangle glyph is always shown by default. The SingleChoiceAction does not currently provide built-in means for replacing a dropdown with a simple button either.
    Currently, to improve user experience with such configurations, you can customize the underlying bar item in the YourSolutionName.Module.Win project.

    XAF 16.2-17.2.5
    You can use the following controller to hide a drop-down list from the NewObjectAction in case it contains only one element:

    C#
    namespace MainDemo.Module.Win.Controllers { using DevExpress.ExpressApp; using DevExpress.ExpressApp.Actions; using DevExpress.ExpressApp.Win.SystemModule; using DevExpress.XtraBars; public class CustomizeNewActionController : ViewController { BarButtonItem newActionBarButtonItem; SingleChoiceAction newObjectAction; protected override void OnActivated() { base.OnActivated(); WinNewObjectViewController newObjectViewController = Frame.GetController<WinNewObjectViewController>(); if(newObjectViewController != null) { newObjectAction = newObjectViewController.NewObjectAction; newObjectAction.CustomizeControl += NewObjectAction_CustomizeControl; newObjectAction.ItemsChanged += NewObjectAction_ItemsChanged; } } protected override void OnDeactivated() { base.OnDeactivated(); if(newObjectAction != null) { newObjectAction.CustomizeControl -= NewObjectAction_CustomizeControl; newObjectAction.ItemsChanged -= NewObjectAction_ItemsChanged; newObjectAction = null; newActionBarButtonItem = null; } } private void NewObjectAction_ItemsChanged(object sender, ItemsChangedEventArgs e) { AdjustAction(); } private void NewObjectAction_CustomizeControl(object sender, CustomizeControlEventArgs e) { newActionBarButtonItem = e.Control as BarButtonItem; AdjustAction(); } private void AdjustAction() { if(newActionBarButtonItem != null) { int visibleChoicesCount = 0; foreach(var item in newObjectAction.Items) { if(item.Active && item.Enabled) { visibleChoicesCount++; } } if(visibleChoicesCount == 1) { newActionBarButtonItem.ButtonStyle = BarButtonStyle.Default; } } } } }

    Here are screenshots showing the results in the application UI before and after this customization.

    Before:

    After:

    If you test our MainDemo.Win app, you can open a DetailView for the User or Role objects and notice that the nested ListView's New Action now looks differently.

    Also, you can use the same approach with the CloneObjectAction (it is a part of the CloneObjectViewController). Refer to the following documentation articles to learn more about this solution:
        Concepts > Extend Functionality > Built-in Controllers and Actions
        Concepts > Extend Functionality > Customize Controllers and Actions
        Task-Based Help > How to: Customize Action Controls
        DevExpress.XtraBars > BarButtonItem > ButtonStyle
        DevExpress.XtraBars > BarButtonItem > ActAsDropDown

    For older versions
    Check out the How to display a dropdown without a triangle glyph for a SingleChoiceAction ticket for code examples.

      Show previous comments (4)

        Hi Devexpress Team,
        We would like to see an option to hide the drop-down arrow for New/Clone actions also. For our use case, we feel that the drop-down adds unnecessary clutter and complexity to the UI.
        Thanks for your consideration.
        Regards,
        Geoff.

          Hi,
          I agree the drop-down should be invisible when only the CurrentObject can be created.

            I agree too

            Other Answers

            created 7 years ago

            Dennis, your sample wasn't working for me in 17.1 so I modified it to be a ViewController. I also adjusted the events so they both attempt to update the action since the events were not firing in a consistent order.

            C#
            public class CustomizeNewActionController : ViewController { BarButtonItem newActionBarButtonItem; SingleChoiceAction newObjectAction; protected override void OnActivated() { base.OnActivated(); WinNewObjectViewController newObjectViewController = Frame.GetController<WinNewObjectViewController>(); newObjectAction = newObjectViewController.NewObjectAction; newObjectAction.CustomizeControl += NewObjectAction_CustomizeControl; newObjectAction.ItemsChanged += NewObjectAction_ItemsChanged; } protected override void OnDeactivated() { base.OnDeactivated(); if (newObjectAction != null) { newObjectAction.CustomizeControl -= NewObjectAction_CustomizeControl; newObjectAction.ItemsChanged -= NewObjectAction_ItemsChanged; newObjectAction = null; newActionBarButtonItem = null; } } private void NewObjectAction_ItemsChanged(object sender, ItemsChangedEventArgs e) { AdjustAction(); } private void NewObjectAction_CustomizeControl(object sender, CustomizeControlEventArgs e) { newActionBarButtonItem = e.Control as BarButtonItem; AdjustAction(); } private void AdjustAction() { if (newActionBarButtonItem != null) { int choicesCount = newObjectAction.Items.Count; if (choicesCount == 1) newActionBarButtonItem.ButtonStyle = BarButtonStyle.Default; } } }
              Comments (2)
              Dennis Garavsky (DevExpress) 7 years ago

                @Dave: Thanks for pointing this out. I have retested and updated this ticket's code.

                Dennis Garavsky (DevExpress) 7 years ago

                  @All:
                  I would kindly ask everyone who is interested in this behavior to review Usability change for SingleChoiceAction with a single sub-item - YOUR FEEDBACK IS NEEDED!!! and answer with +1 or -1 in comments to that blog post on whether you would like to have this behavior by default in v17.2 too. If you need to test your real apps live before making a decision, I can provide you with v17.2 or v18.1 hotfix builds. Thanks for your help in advance.

                  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.