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
- 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);
}
}
}
- 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.
- 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.
- 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 Settings, View 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 Editor, S134808, S39105.
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
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
@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.