Ticket S172871
Visible to All Users

StateMachine - Customizing the structure of the ChangeState Action menu

created 11 years ago (modified 9 years ago)

Scenario

At the moment, the ChangeState Action always provides the "Change status to" menu item holding actual state items:

However, if there is a single state machine registered for the target business object, it would be easier for end-users to avoid this intermediate group item.

Answers approved by DevExpress Support

created 9 years ago (modified 9 years ago)

We have implemented the functionality described in this ticket. It will be included in our next update(s).

Please check back and leave a comment to this response to let us know whether or not this solution addresses your concerns.

Additional information:

Starting with v15.2.6, you can easily enable the ChangeState Action behavior demonstrated in my last screenshot (1-level drop-down menu with group separators, which is the behavior most expected here by user according to the recent survey we conducted) using the built-in ChangeStateActionItemsMode property of the StateMachineController class:

C#
using DevExpress.ExpressApp; using DevExpress.ExpressApp.StateMachine; namespace FeatureCenter.Module.Controllers { public class CustomizeStateMachineController : Controller { protected override void OnFrameAssigned() { base.OnFrameAssigned(); Frame.GetController<StateMachineController>().ChangeStateActionItemsMode = ChangeStateActionItemsMode.FlatList; } } }

If you want to test this right away, you can install this hot fix build: http://downloads.devexpress.com/Share/DXP/160215/DevExpressComponents-15.2.5.16046.exe (this link can be unavailable after the official release):

This new ChangeStateActionItemsMode.FlatList mode will be the default starting with v16.1, so you will not longer need to enable it explicitly in your code.

Thanks,
Dennis

    created 9 years ago (modified 9 years ago)

    To customize the default structure of the ChangeState Action only when one state machine is registered for the target business object, consider handling the ActionStateUpdated event of the StateMachineController class responsible for generating the target Action from a custom Controller created in YourSolutionName.Module project:

    C#
    using System; using DevExpress.ExpressApp; using System.Collections.Generic; using DevExpress.ExpressApp.Actions; using DevExpress.ExpressApp.StateMachine; namespace FeatureCenter.Module.Controllers { public class CustomizeStateMachineController : Controller { //Dennis: Controls whether to customize the default structure when multiple state machines are registered for the target business object. public bool PlainMenuForMultipleMachines { get; set; } public CustomizeStateMachineController() { PlainMenuForMultipleMachines = true; } protected override void OnFrameAssigned() { base.OnFrameAssigned(); Frame.GetController<StateMachineController>().ActionStateUpdated += CustomizeChangeStateActionController_ActionStateUpdated; } private void CustomizeChangeStateActionController_ActionStateUpdated(object sender, EventArgs e) { StateMachineController stateMachineController = (StateMachineController)sender; List<ChoiceActionItem> plainItems = new List<ChoiceActionItem>(); //Dennis: To prevent an accidental status change without seeing its label. stateMachineController.ChangeStateAction.ShowItemsOnClick = true; foreach(ChoiceActionItem groupItem in stateMachineController.ChangeStateAction.Items) { if(groupItem.Data is IStateMachine) { if(PlainMenuForMultipleMachines) { groupItem.Items[0].BeginGroup = true; } foreach(ChoiceActionItem subItem in groupItem.Items) { plainItems.Add(subItem); //subItem.ImageName = "Attention"; //Dennis: Optionally, provide an image for the status item. } } } stateMachineController.ChangeStateAction.Items.Clear(); stateMachineController.ChangeStateAction.Items.AddRange(plainItems); } } }

    Take special note that the Action's ShowItemsOnClick property is also set to True to prevent accidental status changes.

    You will see the following result in the UI (by example of our FeatureCenter demo):

    Take special note that you can control whether to customize the default structure when multiple state machines are registered for the target business object via the PlainMenuForMultipleMachines property:

    PlainMenuForMultipleMachines = False

    PlainMenuForMultipleMachines = True


    I am looking forward to hearing from you on this solution.

      Show previous comments (5)
      Dennis Garavsky (DevExpress) 9 years ago

        @Alexandre: Am I correct that by this, you are referring to the 1-level drop-down menu with group separators (PlainMenuForMultipleMachines = True) I illustrated above? I am asking to clarify this because I cannot easily imagine a usable drop down box in the DetailView layout for this task.

          @Denis Yes a in-detail-view XtraEditors.DropDownButton showing the popup menu like in your PlainMenuForMultipleMachines = True image above would be perfect. Currently the disabled combo used to show the status in the detail view is not really useful. The ability to change the status directly from a drop down in the detail form would make filling forms more fluid IMO. Can't wait to test this in 15.2.6.

          Dennis Garavsky (DevExpress) 9 years ago

            @Alexandre: OK, thanks for your answer. We look forward to hearing from you once you have had an opportunity to test the new mode in v15.2.6.

            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.