Built in auto suggestion editor override

Vote:
 

We've used the built in auto suggestion editor as described here http://world.episerver.com/blogs/Linus-Ekstrom/Dates/2014/7/Built-in-auto-suggestion-editor/ and it's very good however there is one change I would like to see and I wondered if anyone could suggest how to implement this.

When you start typing and get some results the first result is automatically selected which in most cases is fine (but not always). Is there any way to prevent the first item being selected - I don't think there is at present.

Thanks,

Mark

#142304
Dec 08, 2015 17:02
Vote:
 

You can try to make your own attribute and pass configuration to the dojo editor. This is a sample that I haven't tested:

using System;
using System.Web.Mvc;
using EPiServer.Shell.ObjectEditing;

namespace Alloy.ObjectEditing
{
    public class CustomAutoSuggestSelectionAttribute : AutoSuggestSelectionAttribute, IMetadataAware
    {
        public CustomAutoSuggestSelectionAttribute(Type selectionFactoryType) : base(selectionFactoryType)
        {
        }

        public new void OnMetadataCreated(ModelMetadata metadata)
        {
            base.OnMetadataCreated(metadata);

            var extendedMetadata = metadata as ExtendedMetadata;

            if (extendedMetadata == null)
            {
                return;
            }

            extendedMetadata.EditorConfiguration["autoComplete"] = false;
        }
    }
}

Then you can decorate your property with this attribute instead:

[CustomAutoSuggestSelection(typeof(MySelectionQueryFactory))
public virtual string MyProperty { get; set; }
#142330
Dec 09, 2015 11:21
Vote:
 

Hi Mattias,

That did exactly what I needed, thanks for your help,

Mark

#142686
Dec 18, 2015 10:35
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.