Ticket S171794
Visible to All Users

ConditionalAppearance - How to avoid excessive Appearance and ImmediatePostData rule updates and improve overall form performance

created 12 years ago (modified 6 years ago)

Common
1. Remove ImmediatePostData attributes from your properties, where it is possible.
2. Suppress intermediate property change notifications and raise only a single notification when the batch modification is finished as described at Performance impact with ConditionalAppearance.

You can also consider one of the following solutions for different View types that reduce ObjectChanged events upon every key press (until the editor value is validated):

DetailView

  1. Suppress raising the ObjectChanged event on every key press by setting the DetailView.RaiseObjectChangedOnControlValueChanged property to False (undocumented and hidden from Intellisense):
C#
public class ViewController1 : ViewController<DetailView> { public ViewController1() { TargetViewId = "YourObjectType_DetailView"; } protected override void OnActivated() { base.OnActivated(); View.RaiseObjectChangedOnControlValueChanged = false; } }

This code is not required in v19.2+. For more information, see the following breaking change: Core - The IObjectSpace.ObjectChanged event is no longer raised on control value changes because of performance reasons.
2.Temporarily disable the AppearanceController using the following controller as per Access Editor Settings:

C#
using System; using System.Collections.Generic; using System.Linq; using System.Text; using DevExpress.ExpressApp.SystemModule; using Solution5.Module.BusinessObjects; using DevExpress.ExpressApp; using DevExpress.ExpressApp.Editors; using DevExpress.XtraEditors; using DevExpress.ExpressApp.ConditionalAppearance; namespace Solution5.Module.Win.Controllers { public class MyController : ViewController<DetailView> { public MyController() { TargetObjectType = typeof(DomainObject1); } protected override void OnActivated() { base.OnActivated(); PropertyEditor propertyEditor = ((DetailView)View).FindItem("Name") as PropertyEditor; if(propertyEditor != null) { if(propertyEditor.Control != null) { InitEditValue(propertyEditor); } else { propertyEditor.ControlCreated += new EventHandler<EventArgs>(propertyEditor_ControlCreated); } } } protected AppearanceController AppearanceController { get { return Frame.GetController<AppearanceController>(); } } private void propertyEditor_ControlCreated(object sender, EventArgs e) { InitEditValue((PropertyEditor)sender); } private void InitEditValue(PropertyEditor propertyEditor) { ((BaseEdit)propertyEditor.Control).Modified += new EventHandler(MyController_Modified); ((BaseEdit)propertyEditor.Control).Validated += new EventHandler(MyController_Validated); } void MyController_Modified(object sender, EventArgs e) { AppearanceController.Active.SetItemValue("MyKey", false); } void MyController_Validated(object sender, EventArgs e) { AppearanceController.Active.SetItemValue("MyKey", true); } } }
  1. Reduce the number of appearance rules or force them to work for layout groups rather than for individual items. You should also avoid mixing appearance rules with the LayoutItem and ViewItem types whenever possible on the same form.
  2. Consider reworking your View layout and user flow to avoid excessive hide/disable editor operations. For instance, you can show separate forms using Actions instead of layout tabs.
  3. Replace unconditional Appearance rules (without any criteria so they are always applied, like bold font or background color) with direct control customization in ViewControllers (Access Editor SettingsView Items Layout Customization) or HTML Formatting.

ListView
Create a GridListEditor descendant and override its OnObjectChanged method. In this method check the GridView.IsEditing property and do not raise the notification if it returns True (we cannot guarantee that everything will work correctly in all the scenarios after this, test carefully). Examples: How to: Implement a Custom WinForms List EditorS134808S39105.

For more information on use-case scenarios, refer to the following tickets:
    Appearance is refreshed with every keystroke
    Low Performance in MasterDetail-Mode
    Extreme Performance loss with RepositoryItemButtonEdit when MasterDetailMode = ListViewAndDetailView
    RepositoryTextEdit very slow in ListPropertyEditor in DetailView
    Slow typing with high CPU usage
    The Save button gets active and appearance rules are evaluated on every key press even if ImmediatePostData=False

Comments (2)
GA GA
Gerhard Achrainer 12 years ago

    Hi Dennis,
    would it also make sense to add a configurable delay for the controller? If I, for instance, modify a bunch of fields (and maybe dependencies) within a single object, I'd like the appearance controller to "wait" until all updates are done before it applies it's rules.
    Gerhard

    Dennis Garavsky (DevExpress) 12 years ago

      @Gerhard: Yes, it makes sense under certain complex scenarios, but I think that this option should not be default in the framework, at least based on the number of customer requests close to zero. In other words, it is possible to implement this by writing custom code that will depend on a timer or other factors.

      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.