Search This Blog

Thursday, October 19, 2017

How to group validation rules by a business type in Model Editor

If you want the same UI as in the screenshot below:

implement a few code lines in YourSolutionName.Module/Module.cs file, as follows:

using DevExpress.ExpressApp.ModelEditor;
using DevExpress.ExpressApp.Validation;
using DevExpress.ExpressApp.Model;

namespace MainDemo.Module {
    public sealed partial class MainDemoModule : ModuleBase {
        public MainDemoModule() {
            typeof(IModelValidationRules), node => DefaultGroupPathCalculator("TargetType.Name", node));
        public string[] DefaultGroupPathCalculator(string propertyName, IModelNode modelNode) {
            string groupName = "";
            object propertyValue = ModelEditorGroupingHelper.Instance.GetPropertyValue(propertyName, modelNode);
            if(propertyValue != null) {
                groupName = propertyValue.ToString();
            return ModelEditorGroupingHelper.Instance.SplitGroupPath(groupName, modelNode);

This is just one example of the Model Editor nodes grouping customizations that you can achieve with the ModelEditorGroupingHelper  API.

I remember our loyal customer Mario Blataric doing magic using this helper for his specific project needs (multi-level grouping of Actions by Controllers and their namespaces/functional blocks). If you have similar needs in your project, feel free to contact our support team so we can help you make your life easier.