protected override void DropInColumnGroupsView(
            ColumnGroupsViewDefinition view,
            GridViewColumn column,
            RadPosition dropPosition)
        {
            GridViewDataColumn gridViewDataColumn = column as GridViewDataColumn;

            if (gridViewDataColumn != null)
            {
                if (this.ViewTemplate.AllowColumnReorder && this.GridViewGroupColumn.Group.Groups.Count == 0)
                {
                    GridViewColumnGroupRow row = this.FindRow(view.ColumnGroups, (GridViewColumn)gridViewDataColumn);
                    if (this.GridViewGroupColumn.Group != null && this.GridViewGroupColumn.Group.Rows.Count == 0 && (dropPosition & RadPosition.Bottom) != RadPosition.None)
                    {
                        this.GridViewGroupColumn.Group.Rows.Add(new GridViewColumnGroupRow());
                    }
                    if (this.GridViewGroupColumn.Group != null && this.GridViewGroupColumn.Group.Rows.Count > 0)
                    {
                        if (row != null)
                        {
                            row.ColumnNames.Remove(gridViewDataColumn.Name);
                            if (row.ColumnNames.Count == 0)
                            {
                                this.FindGroup(view.ColumnGroups, row)?.Rows.Remove(row);
                            }
                        }
                        if ((dropPosition & RadPosition.Left) != RadPosition.None)
                        {
                            this.GridViewGroupColumn.Group.Rows[0].ColumnNames.Insert(0, gridViewDataColumn.Name);
                        }
                        else
                        {
                            this.GridViewGroupColumn.Group.Rows[0].ColumnNames.Add(gridViewDataColumn.Name);
                        }
                    }
                }
                if (!column.IsVisible && this.GridViewGroupColumn.Group.Groups.Count == 0)
                {
                    column.IsVisible = true;
                }
                else
                {
                    ColumnGroupRowLayout rowLayout = this.TableElement.ViewElement.RowLayout as ColumnGroupRowLayout;
                    rowLayout.InvalidateLayout();
                    rowLayout.InvalidateRenderColumns();
                    this.TableElement.ViewElement.UpdateRows(true);
                }
            }
            else
            {
                if (!(column is GridViewGroupColumn))
                {
                    return;
                }
                this.DropColumnGroup(view, ((GridViewGroupColumn)column).Group, dropPosition);
            }
        }
        private void DropColumnGroup(
            ColumnGroupsViewDefinition view,
            GridViewColumnGroup group,
            RadPosition dropPosition)
        {
            ColumnGroupCollection groupCollection1 = this.FindGroupCollection(view, this.GridViewGroupColumn.Group);
            ColumnGroupCollection groupCollection2 = this.FindGroupCollection(view, group);
            int index = groupCollection1.IndexOf(this.GridViewGroupColumn.Group);

            if (groupCollection1 == groupCollection2 && groupCollection2 != null && groupCollection2.IndexOf(group) < index)
            {
                --index;
            }
            if (group.Parent != null)
            {
                group.Parent.Groups.Remove(group);
            }
            else
            {
                view.ColumnGroups.Remove(group);
            }
            if ((dropPosition & RadPosition.Bottom) != RadPosition.None && this.GridViewGroupColumn.Group.Rows.Count == 0)
            {
                this.GridViewGroupColumn.Group.Groups.Add(group);
            }
            else if ((dropPosition & RadPosition.Left) != RadPosition.None)
            {
                groupCollection1.Insert(index, group);
            }
            else if (index < groupCollection1.Count - 1)
            {
                groupCollection1.Remove(group);
                groupCollection1.Insert(index + 1, group);
            }
            else
            {
                groupCollection1.Add(group);
            }
            if (!group.IsVisible)
            {
                group.IsVisible = true;
            }
            ColumnGroupRowLayout rowLayout = this.TableElement.ViewElement.RowLayout as ColumnGroupRowLayout;

            rowLayout.InvalidateLayout();
            rowLayout.InvalidateRenderColumns();
            this.TableElement.ViewElement.UpdateRows(true);
        }
Exemple #3
0
        private void BestFitGroupColumn(
            GridViewGroupColumn column,
            bool bestFitChildColumns,
            BestFitColumnMode?mode)
        {
            GridTableHeaderRowElement headerRowElement = this.GetHeaderRowElement();
            IVirtualizedElementProvider <GridViewColumn> elementProvider = this.tableElement.ColumnScroller.ElementProvider;
            ColumnGroupRowLayout rowLayout = this.tableElement.ViewElement.RowLayout as ColumnGroupRowLayout;

            if (rowLayout == null || headerRowElement == null)
            {
                return;
            }
            GridColumnGroupCellElement element = elementProvider.GetElement((GridViewColumn)column, (object)headerRowElement) as GridColumnGroupCellElement;

            if (element == null || !element.CanBestFit(column.AutoSizeMode))
            {
                return;
            }
            float num = this.MeasureCell((GridRowElement)headerRowElement, (GridViewColumn)column, element);

            this.Detach(elementProvider, (GridCellElement)element);
            ColumnGroupsCellArrangeInfo columnData = rowLayout.GetColumnData((GridViewColumn)column);

            if ((double)columnData.Bounds.Width < (double)num)
            {
                rowLayout.StartColumnResize((GridViewColumn)column);
                rowLayout.ResizeColumn((int)((double)num - (double)columnData.Bounds.Width));
                rowLayout.InvalidateLayout();
                this.TableElement.ViewElement.InvalidateMeasure(true);
                this.TableElement.ViewElement.UpdateLayout();
                rowLayout.EndColumnResize();
            }
            if (!bestFitChildColumns)
            {
                return;
            }
            foreach (GridViewColumn dataColumn in this.GetDataColumns(column.Group))
            {
                this.BestFitColumnCore(dataColumn, mode.HasValue ? mode.Value : column.AutoSizeMode);
            }
        }