public static void AddDynamicColumns(IGridCreateParameters gridCreateParameter) { if (gridCreateParameter.HeaderList == null) { throw new ArgumentException("HeaderList required"); } if (gridCreateParameter.ExistingBand == null) { throw new ArgumentException("ExistingBand required"); } var view = gridCreateParameter.GetView(); if (view == null) { throw new ArgumentException("View required"); } view.BeginDataUpdate(); var visibleIndexValue = 0; foreach (GridColumn column in gridCreateParameter.ExistingBand.Columns) { if (column.VisibleIndex > visibleIndexValue) { visibleIndexValue = column.VisibleIndex; } } var propertyListSorted = GetComparer(gridCreateParameter); try { foreach (IDynamicProperty property in propertyListSorted) { var newColumn = CreateColumn(property, ref visibleIndexValue, gridCreateParameter.Options.ColumnOptions); gridCreateParameter.ExistingBand.Columns.Add(newColumn); CreateFilterCriteria(property, newColumn); } } finally { view.EndDataUpdate(); } }
public static void AddDynamicBand(IGridCreateParameters gridCreateParameter) { if (gridCreateParameter.HeaderList == null) { throw new ArgumentException("HeaderList required"); } if (gridCreateParameter.ExistingGridView == null) { throw new ArgumentException("ExistingGridView required"); } if (gridCreateParameter.Options.BandOptions.BandIdentifier == null) { throw new ArgumentException("BandIdentifier required"); } if (gridCreateParameter.ExistingBand != null && !ReferenceEquals(gridCreateParameter.ExistingGridView, gridCreateParameter.ExistingBand.View)) { throw new ArgumentException( "View from Band does not match ExistingGridView. Wrong view or wrong band used."); } var view = gridCreateParameter.GetView(); view.BeginDataUpdate(); try { var newChildBand = new GridBand { Tag = gridCreateParameter.Options.BandOptions.BandIdentifier.Key, Caption = gridCreateParameter.Options.BandOptions.BandIdentifier.DisplayName, ToolTip = gridCreateParameter.Options.BandOptions.BandIdentifier.Description }; newChildBand.AppearanceHeader.TextOptions.HAlignment = gridCreateParameter.Options.BandOptions.HorzAlign; newChildBand.AppearanceHeader.Options.UseTextOptions = true; if (gridCreateParameter.ExistingBand != null) { gridCreateParameter.ExistingBand.Children.Add(newChildBand); } else { gridCreateParameter.ExistingGridView.Bands.Add(newChildBand); } var visibleIndexValue = 0; foreach (GridColumn column in newChildBand.Columns) { if (column.VisibleIndex > visibleIndexValue) { visibleIndexValue = column.VisibleIndex; } } var propertyListSorted = GetComparer(gridCreateParameter); foreach (IDynamicProperty property in propertyListSorted) { var newColumn = CreateColumn(property, ref visibleIndexValue, gridCreateParameter.Options.ColumnOptions); newChildBand.Columns.Add(newColumn); CreateFilterCriteria(property, newColumn); } } finally { view.EndDataUpdate(); } }
public static void AddDynamicBandsAndColumnsViaGroupCriteria(IGridCreateParameters gridCreateParameter) { if (gridCreateParameter.HeaderList == null) { throw new ArgumentException("HeaderList required"); } if (gridCreateParameter.ExistingBand == null) { throw new ArgumentException("ExistingBand required"); } var view = gridCreateParameter.GetView(); if (view == null) { throw new ArgumentException("View required"); } view.BeginDataUpdate(); var propertyListSorted = GetComparer(gridCreateParameter); try { foreach (IDynamicProperty property in propertyListSorted) { Debug.Assert(property.GroupCriteria != null && property.GroupCriteria.Key != null, "Group-Criteria muss gefüllt sein, sonst gibt's keine Bänder"); GridBand childBand = null; foreach (GridBand band in gridCreateParameter.ExistingBand.Children) { var bandName = band.Tag as string; if (bandName == property.GroupCriteria.Key) { childBand = band; break; } } if (childBand == null) { childBand = new GridBand { Tag = property.GroupCriteria.Key, Caption = property.GroupCriteria.DisplayName, ToolTip = property.GroupCriteria.Description }; gridCreateParameter.ExistingBand.Children.Add(childBand); } var visibleIndexValue = 0; foreach (GridColumn column in childBand.Columns) { if (column.VisibleIndex > visibleIndexValue) { visibleIndexValue = column.VisibleIndex; } } var newColumn = CreateColumn(property, ref visibleIndexValue, gridCreateParameter.Options.ColumnOptions); childBand.Columns.Add(newColumn); CreateFilterCriteria(property, newColumn); } } finally { view.EndDataUpdate(); } }