Try our conversational search powered by Generative AI!

CheckBoxListEditor not working

Vote:
 

Hi.

 

I am working on a tagging-system where I want to implement a CheckBoxListEditor for the tags. However wwhen I set the ClientEditingClass to epi.cms.contentediting.editors.CheckBoxListEditor the formediting does not load. (The loading-gif just keeps working). When I use SelectionEditor instead it works but I need to be able to use multiple tags.

Property definitions

        [UIHint("Tagging")]
        [Display(
            Name = "Taggar",
            Description = "Taggar för att sortera innehåll i till exempel sökningar och listningar")]
        public virtual string Tags { get; set; }

    EditorDescriptor:

[EditorDescriptorRegistration(TargetType = typeof(string), UIHint = "Tagging")]
        public class PersonEditorDescriptor : EditorDescriptor
        {
            public override void ModifyMetadata(EPiServer.Shell.ObjectEditing.ExtendedMetadata metadata, System.Collections.Generic.IEnumerable<Attribute> attributes)
            {
                SelectionFactoryType = typeof(TagSelectionFactory);
                ClientEditingClass = "epi.cms.contentediting.editors.CheckBoxListEditor";

                base.ModifyMetadata(metadata, attributes);
            }
        }

    TagSelectionFactory:

    public class TagSelectionFactory : ISelectionFactory
    {
        public IEnumerable<ISelectItem> GetSelections(ExtendedMetadata metadata)
        {
            List<SelectItem> Tags = new List<SelectItem>();
            bool TagsExists = true;
            int n = 1;
            while (TagsExists)
            {
                if ((WebConfigurationManager.AppSettings["tag:" + n] != null) && (!string.IsNullOrEmpty(WebConfigurationManager.AppSettings["tag:" + n].ToString())))
                {
                    Tags.Add(new SelectItem{
                        Value = n,
                        Text = WebConfigurationManager.AppSettings["tag:" + n].ToString()
                    });
                }
                else
                {
                    TagsExists = false;
                }
                n++;
            }
            return Tags;
        }
    }

    

Thanks in advance,

David Rutqvist

 

#70662
Apr 25, 2013 8:42
Vote:
 

You shouldn't set the SelectionFactoryType or ClientEditingClass in the ModifyMetadata. You should do that in your constructor instead.

[EditorDescriptorRegistration(TargetType = typeof(string), UIHint = "Tagging")]
public class PersonEditorDescriptor : EditorDescriptor
{
    public PersonEditorDescriptor()
    {
        SelectionFactoryType = typeof(TagSelectionFactory);
        ClientEditingClass = "epi.cms.contentediting.editors.CheckBoxListEditor";
    }
}

    

#70677
Edited, Apr 25, 2013 16:51
Vote:
 

Turns out that did not work either. The loading-gif just keeps spinning.

#70721
Apr 29, 2013 7:24
Vote:
 

What version are you running? Have you upgraded to EPiServer 7.1?

#70723
Apr 29, 2013 8:50
Vote:
 

After upgrading to 7.1 you need to change the client edtiting class away from the dot-syntax. Something to do with upgrading some dojo stuff to 1.8.

See section "Dojo 1.8 upgrade"

Something like "epi-cms/contentediting/editors/CheckBoxListEditor" should work. If this is related to a 7.1-version, that is.

Why it works for drop down lists and not check box lists after upgrading I don’t understand, though.

 

#70728
Apr 29, 2013 10:17
Vote:
 

Yeah that did the trick. However when I save the page and then go back to edit mode the checkboxes are not checked. Am I missing something or do I have to check them all by myself (how to set checked=true then?).

 

EDIT: Should also say that the tag name and value are different (E.g. Fruits => 1)

#70732
Edited, Apr 29, 2013 11:01
Vote:
 

Try to set the value on the select items to a string (Value = n.ToString()) when you create select items in your selection factory class. That should solve the pre-selecting issue I think. It seems like string are the only way to go when dealing with these select item values.

#70733
Apr 29, 2013 11:09
Vote:
 

Worked like a charm! All problems solved.

#70830
May 02, 2013 7:17
Vote:
 

I currently have my values as strings as such "Small|s|1.00"  is there a reason i cannot select multiple in my checkbox list.  I have updated the framework to the proper dojo "epi-cms/contentediting/editors/CheckBoxListEditor" and all the fun jazz.  it only allows me to save one value, when i select another checkbox in the checkbox list, the values go blank.  I also am having the preselect issue as well.

#71150
May 11, 2013 5:28
Vote:
 

For properties whose value are array, you need to set "multiple" attribute to true in your editor widget.

#71152
May 11, 2013 13:18
Vote:
 

Hey Duong, I guess I am not sure what you are referring to as "Multiple" attribute to true for your editor widget.  Am I missing something.  I do not see it referenced or documented anywhere.  Apologize for my simple question.  This is what i have.

[EditorDescriptorRegistration(TargetType = typeof(EOptionCollection), UIHint = EOptionUIHints.EOptionHints.EOptionCheckBoxLists)]
    public class EOptionCheckBoxListsEditorDescriptor : EditorDescriptor
    {
        public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
        {
            SelectionFactoryType = typeof(EOptionCheckBoxlistsSelectionFactory);

            ClientEditingClass = "epi-cms/contentediting/editors/CheckBoxListEditor";

            base.ModifyMetadata(metadata, attributes);
        }

        public class EOptionCheckBoxlistsSelectionFactory : ISelectionFactory
        {
            public IEnumerable<ISelectItem> GetSelections(ExtendedMetadata metadata)
            {
                PropertyData propertyData = metadata.Model as PropertyData;

                if (propertyData == null)
                {
                    yield break;
                }

                EOptionSettings settings = (EOptionSettings)propertyData.GetSetting(typeof(EOptionSettings));

                foreach (EOptionItem item in EOptionCollection.ParseJson(settings.EOptionCollectionString))
                {
                    yield return new SelectItem { Text = item.Name, Value = item.ToString() };
                }
            }
        }
    }

    

#71153
May 11, 2013 15:13
Vote:
 

Basically, you should just have to add the following code in the ModifyMetadata method:

EditorConfiguration["multiple"] = true;

Read more about how to define settings here: http://world.episerver.com/Blogs/Linus-Ekstrom/Dates/2013/4/Sending-settings-from-the-server-to-your-edito

#71160
May 13, 2013 7:46
Vote:
 

I only had this problem when having a Container Page (without template) and a property refering to an editordescriptor with ClientEditingClass = "epi.cms.contentediting.editors.CheckBoxListEditor"


Changing to "epi-cms/contentediting/editors/CheckBoxListEditor" helped, thanks!

Is it possible to add some information about the name convention changes to the SDK, documentation and articles written by EPiServer? That developer blogs still have the old convention is kinda hard to fix but having the official documentation corrected would be nice.

#72232
Edited, Jun 11, 2013 14:23
Vote:
 

There is documentation about this in the release notes. http://world.episerver.com/Documentation/Items/Release-Notes/EPiServer-CMS/EPiServer-7/Release-Notes--EPiServer-7-1-CMS/?id=66142&epslanguage=en#js

But this is probably not visible enough. I can talk to the documentation team to see if we can make this more visible in the SDK.

#72233
Jun 11, 2013 14:43
Vote:
 

Yeah I've read that but that part must have slipped my mind when it stopped working for me.

I think updating the original articles would be good for new developers that might now have updated themselves with the new patches and updates. If you could push some changes it would be nice.

#72234
Jun 11, 2013 14:50
Vote:
 

1. I have updated the sample with the 7.1 namespaces.

2. Regarding future improvements I hope we can add descriptor base classes that makes this even simpler for the next release so you don't have to care about the editors being used.

#72291
Jun 12, 2013 15:51
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.