Created
July 8, 2015 07:48
-
-
Save gregwiechec/bb63f5a218ca9696e87e to your computer and use it in GitHub Desktop.
Extended CheckboxList property
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
define([ | |
"dojo/_base/declare", | |
"dojo/_base/array", | |
"epi-cms/contentediting/editors/CheckBoxListEditor" | |
], function ( | |
declare, | |
array, | |
_CheckBoxListEditor | |
) { | |
return declare("alloy.editors.extendedCheckBoxListEditor", _CheckBoxListEditor, { | |
buildRendering: function () { | |
this.inherited(arguments); | |
if (this.readOnly) { | |
return; | |
} | |
array.forEach(this._checkboxes, this._setCheckboxEnabled, this); | |
}, | |
_setCheckboxEnabled: function(checkbox) { | |
var selectedItem = array.filter(this.selections, function (item) { | |
return item.value == checkbox.value; | |
}, this)[0]; | |
checkbox.set("readOnly", selectedItem.enabled === false); | |
} | |
}); | |
}); |
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
public class ExtendedSelectItem : SelectItem | |
{ | |
public bool Enabled { get; set; } | |
} |
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
public class ProductPage : StandardPage | |
{ | |
//... | |
[ClientEditor(ClientEditingClass = "alloy.editors.extendedCheckBoxListEditor", SelectionFactoryType = typeof(ContinentSelectionFactory))] | |
public virtual string Continents { get; set; } | |
//... | |
} |
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 EPiServer.Shell.ObjectEditing; | |
namespace EpiServerThumbnail.Business.EditorDescriptors | |
{ | |
public class ContinentSelectionFactory: ISelectionFactory | |
{ | |
public IEnumerable GetSelections(ExtendedMetadata metadata) | |
{ | |
var items = new[] | |
{ | |
new ExtendedSelectItem | |
{ | |
Enabled = false, | |
Text = "Australia", | |
Value = "Au" | |
}, | |
new ExtendedSelectItem | |
{ | |
Enabled = true, | |
Text = "Africa", | |
Value = "Af" | |
}, | |
new ExtendedSelectItem | |
{ | |
Enabled = true, | |
Text = "Asia", | |
Value = "As" | |
}, | |
new ExtendedSelectItem | |
{ | |
Enabled = true, | |
Text = "Europe", | |
Value = "Eu", | |
}, | |
new ExtendedSelectItem | |
{ | |
Enabled = true, | |
Text = "North America", | |
Value = "NoAm" | |
}, | |
new ExtendedSelectItem | |
{ | |
Enabled = false, | |
Text = "South America", | |
Value = "SoAm" | |
} | |
}; | |
return items; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment