Enable/Disable SelectItem in SelectionFactory

Vote:
 

Hi!

Does anyone know if it's possible to add custom attributes per SelectItem from a SelectionFactory? I'm creating a property with a custom EditorDescritor to select multiple values in a CheckBoxListEditor (similar to the SelectMultiple attribute)

I would like to have a SelectionFactory generated from a category node. Some of these categories are not selectable and I would like to mimic this behaviour in the CheckBoxListEditor as well. I don't want to hide them or anything, just disable the checkboxes or make them readonly or something like that.

It seems SelectItem only has two properties for Text and Value, so how would I do this?

#123350
Jul 02, 2015 11:18
Vote:
 

Hi,

I think that you need to create a custom widget that inhertis from "epi-cms/contentediting/editors/CheckBoxListEditor"

#123363
Jul 02, 2015 12:58
Vote:
 

Ok!

If there is no built in support for this, I guess it's the only way. But I'm guessing this is rather complicated since the source for the list is SelectItem? I would probably have to create a custom class for the items as well...

#123364
Jul 02, 2015 13:19
Vote:
 

The SelectionFactory works on ISelectItem interface. You could check what happened when you return object of class:

class ExtendedSelection: ISelectItem
{
    public object Value { get; set; }

    public string Text { get; set; }

    public bool Enabled { get; set; }
}

Then debug JavaScript widget CheckBoxListEditor and check what is inside this.selections property. Maybe there will enabled property as well.

#123366
Jul 02, 2015 13:45
Vote:
 

That's a good idea! I'll try that, thanks.

#123367
Jul 02, 2015 13:47
Vote:
 

Hi,

I prepared the solution and described implementation in a tutorial way. Here is the link.

The full source code is available on Gists.

#123615
Jul 10, 2015 11:16
* 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.