Created
November 16, 2018 08:37
-
-
Save simple17/fd1548a746f31d76d036c539dcd573d0 to your computer and use it in GitHub Desktop.
[Seletion Factory] Simple select or list checkboxes property #episerver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Linq; | |
using EPiServer.Shell.ObjectEditing; | |
namespace Project.Business.Selection | |
{ | |
public class ResourceIconSelection : ISelectionFactory | |
{ | |
public IEnumerable<ISelectItem> GetSelections(ExtendedMetadata metadata) | |
{ | |
var iconsList = new SortedDictionary<string, string>(); | |
iconsList.Add("Link", "link"); | |
iconsList.Add("Media", "media"); | |
iconsList.Add("PDF", "pdf"); | |
return iconsList | |
.Select(x => new SelectItem() { Text = x.Key, Value = x.Value }) | |
.ToArray(); | |
} | |
} | |
} | |
////Next declare property in your model. For select use 'SelectOne' and for list of checkboxes use 'SelectMany'. | |
[SelectOne(SelectionFactoryType = typeof(ResourceIconSelection))] | |
[Display( | |
Name = "Icon", | |
GroupName = SystemTabNames.Content, | |
Order = 10)] | |
public virtual string Icon { get; set; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment