Custom Editors

2 posts, 0 answers
  1. Vaggelis
    Vaggelis avatar
    4 posts
    Member since:
    Apr 2016

    Posted 22 Apr 2016 Link to this post


    I am trying to create a custom editor for one of my properties. The code I use is this:


        public class ReaderEditor : Com.Telerik.Widget.Dataform.Visualization.Core.EntityPropertyEditor
            public ReaderEditor(RadDataForm form, IEntityProperty property) : base(form,

            public ReaderEditor(RadDataForm dataForm, int layoutId, int headerLayoutId,
                int headerViewId, int editorLayoutId, int editorViewId,
                int validationLayoutId, IEntityProperty property) :

                base(dataForm, layoutId, headerLayoutId, headerViewId, editorLayoutId,
                    editorViewId, validationLayoutId, property)

            public override Java.Lang.Object Value()
                return ((EditText)EditorView).Text;

            protected override void ApplyEntityValueToEditor(Java.Lang.Object entityValue)
                ((EditText)EditorView).Text = entityValue.ToString();


    It's pretty basic actually, I just wanted to create a simple one in order to build on that afterwards. However when I run it I get the following exception:


    Java.Lang.Error: The data form editor for property MYPROPERTY must have a constructor that accepts a Context and an EntityProperty.


    How can I implement this editor?

    Thank you for your time,


  2. Todor
    Todor avatar
    798 posts

    Posted 27 Apr 2016 Link to this post

    Hello Vaggelis,

    From the provided information I can't reproduce an issue. Since you haven't included a full project but simply the custom editor class, I'd like to point out a few details which may be the cause for your issue.

    1) "form.EditorsHeaderLayout" should be a layout for the header and "Resource.Id.data_form_text_viewer_header1" should be an id inside that layout. If you are using defaults, use the following id: "Resource.Id.data_form_text_viewer_header".
    2) Similarly, the next two parameters are the layout for the editor and an id that's inside that layout
    3) When you have your class ready, you can "attach" it to the data form with a custom EditorProvider:

    public class MyEditorProvider : Java.Lang.Object, IFunction {
        private RadDataForm dataForm;
        public MyEditorProvider(RadDataForm dataForm) {
            this.dataForm = dataForm;
        public Java.Lang.Object Apply (Java.Lang.Object p0)
            IEntityProperty property = (IEntityProperty)p0;
            if(property.Name().Equals("EmployeeType")) {
                return new ReaderEditor(dataForm, property);
            return null;

    And here's how to add it to the data form:

    dataForm.Adapter.SetEditorProvider(new MyEditorProvider(dataForm));

    I hope this information helps. If your issue persist, please provide more exact reproduction steps.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top