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(); }
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, Handler = Handler, parent = this }; childController.InitializeItems(children); Sections.Add(childController); } else { bool addTop = true; foreach (var section in sections) { if (row <= section.StartRow) { break; } if (row <= section.StartRow + section.Count) { children = section.ExpandRowInternal(row - section.StartRow - 1); addTop = false; break; } row -= section.Count; } if (addTop && row < Store.Count) { children = (ITreeGridStore <ITreeGridItem>)Store [row]; var childController = new TreeController { StartRow = row, Handler = Handler, parent = this }; childController.InitializeItems(children); Sections.Add(childController); } } Sections.Sort((x, y) => x.StartRow.CompareTo(y.StartRow)); if (children != null) { ClearCache(); ResetCollection(); } return(children); }