public void InitializeItems(ITreeGridStore <ITreeGridItem> store) { ClearCache(); if (sections != null) { sections.Clear(); } Store = store; if (Store != null) { for (int row = 0; row < Store.Count; row++) { var item = Store[row]; if (item.Expanded) { var children = (ITreeGridStore <ITreeGridItem>)item; var section = new TreeController { StartRow = row, Handler = Handler, parent = this }; section.InitializeItems(children); Sections.Add(section); } } } ResetCollection(); }
static IEnumerable <ITreeGridItem> GetParents(ITreeGridItem value) { ITreeGridItem parent = value.Parent; while (parent != null) { yield return(parent); parent = parent.Parent; } }
ITreeGridStore <ITreeGridItem> ExpandRowInternal(int row) { ITreeGridStore <ITreeGridItem> children = null; if (sections == null || sections.Count == 0) { children = (ITreeGridStore <ITreeGridItem>)Store [row]; var childController = new TreeController { StartRow = row, Store = children, Handler = this.Handler, parent = this }; Sections.Add(childController); } else { bool addTop = true; foreach (var section in sections) { if (row <= section.StartRow) { break; } else if (row <= section.StartRow + section.Count) { children = section.ExpandRowInternal(row - section.StartRow - 1); addTop = false; break; } else { row -= section.Count; } } if (addTop && row < Store.Count) { children = (ITreeGridStore <ITreeGridItem>)Store [row]; var childController = new TreeController { StartRow = row, Store = children, Handler = this.Handler, parent = this }; Sections.Add(childController); } } Sections.Sort((x, y) => x.StartRow.CompareTo(y.StartRow)); if (children != null) { ClearCache(); ResetCollection(); } return(children); }