expressappframework-devexpress-dot-expressapp-dot-editors-ce9d284e.md
Registers a custom List Editor in the Application Model.
Namespace : DevExpress.ExpressApp.Editors
Assembly : DevExpress.ExpressApp.v25.2.dll
NuGet Package : DevExpress.ExpressApp
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
public class ListEditorAttribute :
Attribute
<AttributeUsage(AttributeTargets.Class, Inherited:=False, AllowMultiple:=True)>
Public Class ListEditorAttribute
Inherits Attribute
When an XAF application loads, the reflection mechanism locates classes with the ListEditor attribute. The Application Model includes these classes into its List Editor collection. The attribute’s parameter specifies the target object type for the List Editor.
Tip
Use the PropertyEditorAttribute to register a class as a Property Editor.
The ListEditor attribute includes the following parameters:
listElementTypeSets the type of objects that the List Editor can display. Set this parameter to Object to support objects of any type.isDefaultSpecify true to make this List Editor a default choice for the specified object type(s). Otherwise, the List Editor is available in the Model Editor, but you must explicitly assign it to an object type or a List View.
You can specify the default List Editor in two ways:
In code
Apply ListEditorAttribute to your custom List Editor class. Pass Object and true as attribute parameters.
// Set CustomListEditor as the default List Editor
[ListEditor(typeof(object), true)]
public class CustomListEditor : DxGridListEditor { /* ... */ }
In the Model Editor
Use ListEditorAttribute to register your custom List Editor in the Application Model. Pass Object and false as attribute parameters.
// Register CustomListEditor as the available List Editor for properties of any type
[ListEditor(typeof(object), false)]
public class CustomListEditor : DxGridListEditor { /* ... */ }
Open the Model Editor, select Views , and set the DefaultListEditor property to your editor class name.
You can link a custom List Editor to a specific type in the following two ways:
In code
Apply ListEditorAttribute to your editor class. Pass the required data type and true as attribute parameters.
// Assign CustomListEditor to Employee object type
[ListEditor(typeof(Employee), true)]
public class CustomListEditor : DxGridListEditor { /* ... */ }
In the Model Editor
Use ListEditorAttribute to register your custom List Editor in the Application Model. Pass the required data type and false as attribute parameters.
// Register CustomListEditor as the available list editor for Employee objects
[ListEditor(typeof(Employee), false)]
// Or Register CustomListEditor as the available List Editor for properties of any type
//[ListEditor(typeof(object), false)]
public class CustomListEditor : DxGridListEditor { /* ... */ }
To assign this editor to a specific object type, open the Model Editor and select BOModel | {MySolution}.Module.BusinessObjects | {ClassName}. Set the EditorType property to your editor class name.
Register the editor in code as demonstrated in the previous section. In the Model Editor, select Views | {MySolution}.Module.BusinessObjects | {ClassName} | {ClassName}_ListView. Set the EditorType property to your editor class name.
You can disable the mechanism that locates classes decorated with ListEditorAttribute. This change may help you optimize application load time.
To activate manual List Editor registration, override the ModelBase.RegisterEditorDescriptors method. Call the RegisterListEditor method to register required List Editors:
public class CustomListEditor : DxGridListEditor { /* ... */ }
using System.ComponentModel;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Editors;
using MySolution.Module.BusinessObjects;
namespace MySolution.Blazor.Server {
public sealed class MySolutionBlazorModule : ModuleBase {
protected override void RegisterEditorDescriptors(EditorDescriptorsFactory editorDescriptorsFactory) {
editorDescriptorsFactory.RegisterListEditor(typeof(MyBusinessObject), typeof(CustomListEditor), true);
}
//...
}
// ...
}
Refer to the ModuleBase property description for details.
Object Attribute ListEditorAttribute
See Also