private void LoadValue() { if (!ReadOnly && !Disabled) { Value.List valueObject = new Value.List(); foreach (var row in Controls.Filter <Table>().SelectMany(t => t.Rows).Where(r => r.Key != NON_DATA_KEY)) { Value.Item valueItem = new Value.Item(); foreach (var cell in row.Cells.Where(c => c.Key != NON_DATA_KEY)) { valueItem.properties.Add(new Value.Property() { key = cell.Key, value = SitecoreReflected.Instance.GetValue(cell) }); } valueObject.items.Add(valueItem); } valueObject.items = valueObject.items.Where(i => i.properties.Any(p => !string.IsNullOrEmpty(p.value))).ToList(); string serializedValue = valueObject.items.Any() ? valueObject.JsonSerialize() : string.Empty; if (Value != serializedValue) { ValueObject = valueObject; SetModified(); } } }
protected Table GetDataItemControl(Value.Item valueItem) { Table result = new Table() { ID = GetUniqueID(ID) }; Row headerRow = new Row() { Key = NON_DATA_KEY }; Row menuRow = new Row() { Key = NON_DATA_KEY }; Row tableRow = new Row(); headerRow.AddCell(new Cell()); menuRow.AddCell(new Cell()); tableRow.AddCell(GetNavigationCell(result.ID)); foreach (var field in SourceRowTemplate) { string editorId = GetUniqueID(ID); Item fieldItemType = SitecoreReflected.Instance.GetFieldTypeItem(field); headerRow.AddCell(new Cell(new LiteralWithViewState(HttpUtility.HtmlEncode(field.DisplayName ?? field.Name)), NON_DATA_KEY)); menuRow.AddCell(new Cell(SitecoreReflected.Instance.GetMenuButtons(fieldItemType, editorId), NON_DATA_KEY)); System.Web.UI.Control editor = SitecoreReflected.Instance.GetEditor(fieldItemType); SitecoreReflected.Instance.SetProperties(editor, editorId, field, ItemID, ItemVersion, ItemLanguage, ReadOnly); //TODO - Sitecore.Shell.Applications.ContentEditor.EditorFormatter.SetAttributes //TODO - Sitecore.Shell.Applications.ContentEditor.EditorFormatter.SetStyle if (valueItem != null) { SitecoreReflected.Instance.SetValue(editor, valueItem.properties.Where(p => p.key == field.Name).Select(p => p.value).FirstOrDefault()); } tableRow.AddCell(new Cell(editor, field.Name)); } result.AddRow(headerRow); result.AddRow(menuRow); result.AddRow(tableRow); return(result); }