private void UpdateChildRowViewInfo(GridViewRowInfo newRow) { GridViewTemplate parent = this.owner.Parent; if (parent == null) { return; } GridViewRelationDataProvider hierarchyDataProvider = this.owner.HierarchyDataProvider as GridViewRelationDataProvider; if (hierarchyDataProvider == null) { return; } hierarchyDataProvider.Refresh(); foreach (GridViewRowInfo childRow in parent.ChildRows) { bool flag = true; for (int index = 0; index < hierarchyDataProvider.Relation.ParentColumnNames.Count; ++index) { if (!object.Equals(childRow.Cells[hierarchyDataProvider.Relation.ParentColumnNames[index]].Value, newRow.Cells[hierarchyDataProvider.Relation.ChildColumnNames[index]].Value)) { flag = false; break; } } if (flag) { using (IEnumerator <GridViewInfo> enumerator = ((GridViewHierarchyRowInfo)childRow).Views.GetEnumerator()) { while (enumerator.MoveNext()) { GridViewInfo current = enumerator.Current; if (current.ViewTemplate == this.owner) { newRow.ViewInfo = current; break; } } break; } } } }
private void ListSource_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { this.AttachRows(e.NewItems); if (!this.suspendNotifications) { if (this.Count <= 1) { this.owner.DataView.EnsureDescriptors(); } this.UpdateChildRowViewInfo((GridViewRowInfo)e.NewItems[0]); if (((GridViewRowInfo)e.NewItems[0]).Parent is MasterGridViewTemplate) { ++((GridViewRowInfo)e.NewItems[0]).ViewInfo.Version; } this.DispatchDataViewChangedEvent(new DataViewChangedEventArgs(ViewChangedAction.Add, e.NewItems)); if (this.owner.SelectLastAddedRow && e.NewItems.Count > 0) { GridViewSynchronizationService.RaiseCurrentChanged(this.owner, this.owner.DataView.CurrentItem, this.owner.CurrentColumn, this.owner.DataView == null); if (!this.addingThroughUI) { if (this.prevSelectedRow != null) { GridViewSynchronizationService.SuspendEvent(this.owner, KnownEvents.CurrentChanged); this.prevSelectedRow.IsCurrent = false; this.prevSelectedRow.IsSelected = false; GridViewSynchronizationService.ResumeEvent(this.owner, KnownEvents.CurrentChanged); } GridViewRowInfo newItem = (GridViewRowInfo)e.NewItems[0]; newItem.IsCurrent = true; newItem.IsSelected = true; this.prevSelectedRow = newItem; newItem.EnsureVisible(); } } if (this.owner.IsSelfReference) { this.DispatchDataViewChangedEvent(new DataViewChangedEventArgs(ViewChangedAction.SortingChanged)); } } } GridViewInfo gridViewInfo = (GridViewInfo)null; GridViewRowInfo gridViewRowInfo = (GridViewRowInfo)null; bool flag1 = false; if (e.Action == NotifyCollectionChangedAction.Remove) { GridViewRowInfo newItem = e.NewItems[0] as GridViewRowInfo; flag1 = newItem.IsPinned; if (newItem != null && newItem.ViewTemplate != null && newItem.ViewTemplate.HierarchyDataProvider != null) { int val1 = this.owner.MasterTemplate.Owner.TableElement.RowScroller.Scrollbar.Value; newItem.ViewTemplate.HierarchyDataProvider.Refresh(); newItem.ViewTemplate.Refresh(); RadScrollBarElement scrollbar = this.owner.MasterTemplate.Owner.TableElement.RowScroller.Scrollbar; scrollbar.Value = Math.Min(val1, scrollbar.Maximum - scrollbar.LargeChange + 1); } if (newItem != null && newItem.IsCurrent && (this.owner.Parent != null && !this.suspendNotifications)) { gridViewInfo = newItem.ViewInfo; gridViewRowInfo = GridViewRowCollection.NavigateAfterRemove(newItem, (List <GridViewRowInfo>)null); } if (!this.suspendNotifications) { this.DispatchDataViewChangedEvent(new DataViewChangedEventArgs(ViewChangedAction.Remove, e.NewItems)); } } this.OnCollectionChanged(e); if (gridViewInfo != null) { GridViewRelationDataProvider hierarchyDataProvider = gridViewInfo.ViewTemplate.HierarchyDataProvider as GridViewRelationDataProvider; if (hierarchyDataProvider != null && this.owner.MasterTemplate.SynchronizationService.IsDispatchSuspended) { hierarchyDataProvider.Refresh(); } gridViewInfo.Refresh(); } GridViewCollectionChangedEventArgs args = new GridViewCollectionChangedEventArgs(this.owner, e.Action, e.NewItems, e.OldItems, e.NewStartingIndex, e.OldStartingIndex, e.PropertyName); bool flag2 = true; if (e.Action == NotifyCollectionChangedAction.ItemChanging || e.Action == NotifyCollectionChangedAction.ItemChanged) { flag2 = !this.owner.ListSource.IsDataBound || e.Action == NotifyCollectionChangedAction.ItemChanged && !string.IsNullOrEmpty(e.PropertyName); } if (flag2) { this.owner.EventDispatcher.RaiseEvent <GridViewCollectionChangedEventArgs>(EventDispatcher.RowsChanged, (object)this, args); this.UpdateHierarchyView(e.NewItems, e.PropertyName); } if (flag1) { this.DispatchDataViewChangedEvent(new DataViewChangedEventArgs(ViewChangedAction.Remove), GridEventType.UI); } if (gridViewInfo == null || this.owner.MasterTemplate == null) { return; } if (this.owner.MasterTemplate.SynchronizationService.IsDispatchSuspended) { if (gridViewRowInfo == null) { return; } this.owner.MasterTemplate.CurrentRowToSetOnEndUpdate = gridViewRowInfo; } else { if (!flag1) { this.DispatchDataViewChangedEvent(new DataViewChangedEventArgs(ViewChangedAction.Remove), GridEventType.UI); } if (gridViewRowInfo == null) { return; } this.owner.MasterTemplate.CurrentRow = gridViewRowInfo; } }