private List <bool> GetVisibleDescendantExpandStates(int rowIndex) { int i = GetPrimaryId(rowIndex); if (!VisibleDescendantExpandStates.ContainsKey(i)) { VisibleDescendantExpandStates.Add(i, new List <bool>()); } return(VisibleDescendantExpandStates[i]); }
private void ExpandNode(int rowIndex, bool refresh, bool resizeNodeCell, bool expandDescendents) { Node n = GetNode(rowIndex); if (n.Indent > this.MaxIndentLevels) { return; } if (n.HasChildren) { if (refresh) { this.grid.TableControl.BeginUpdate(); } try { int pos = GetPosition(rowIndex); IList list = (n.ChildList == null) ? this.dataSource.GetChildList(n.Position, n.SiblingList, n.ParentNode) : n.ChildList; PopulateIndexer(pos + 1, list, n.Indent + 1, n); n.IsExpanded = true; this.grid.TableControl.Model.ResetVolatileData(); if (resizeNodeCell) { this.grid.TableControl.Model.ColWidths.ResizeToFit(GridRangeInfo.Cells(rowIndex, TREECOLUMN, rowIndex + list.Count, TREECOLUMN), GridResizeToFitOptions.NoShrinkSize); } if (expandDescendents) { ExpandDescendants(rowIndex); int id = GetPrimaryId(rowIndex); if (VisibleDescendantExpandStates.ContainsKey(id)) { VisibleDescendantExpandStates.Remove(id); } } } catch { } finally { if (refresh) { this.grid.TableControl.EndUpdate(); this.grid.TableControl.Refresh(); } } } }
private void CollapseNode(int rowIndex, bool saveExpandStates) { Node n = GetNode(rowIndex); if (n.IsExpanded && n.HasChildren) { if (saveExpandStates) { int id = GetPrimaryId(rowIndex); if (VisibleDescendantExpandStates.ContainsKey(id)) { VisibleDescendantExpandStates[id] = QueryVisibleDescendantsExpandStates(rowIndex); } else { VisibleDescendantExpandStates.Add(id, QueryVisibleDescendantsExpandStates(rowIndex)); } } int i = rowIndex + 1; int pos = GetPosition(i); int rowCount = this.grid.TableControl.Model.RowCount; if (i <= rowCount) { Node next = GetNode(i); this.grid.TableControl.Model.ResetVolatileData(); while (next.Indent > n.Indent && i <= rowCount) { this.rowIndexer.RemoveAt(pos); rowCount--; if (i <= rowCount) { next = GetNode(i); } } } n.IsExpanded = false; this.grid.TableControl.Refresh(); this.grid.Table.Reload(); } }