Пример #1
0
        public static void AddNewGroupFromColumnManagerCell(ColumnManagerCell cell, GroupLevelDescription draggedOverDescription, DropMarkAlignment alignment, DataGridControl parentDataGridControl)
        {
            if (cell == null)
            {
                return;
            }

            DataGridContext cellDataGridContext = DataGridControl.GetDataGridContext(cell);
            DataGridControl cellParentGrid      = cellDataGridContext.DataGridControl;

            if ((cellDataGridContext == null) ||
                (parentDataGridControl == null) ||
                (parentDataGridControl != cellParentGrid))
            {
                return;
            }

            // By default, add it at the end
            int newPos = cellDataGridContext.GroupLevelDescriptions.Count;

            if (draggedOverDescription != null)
            {
                newPos = GroupingHelper.GetGroupDescriptionIndexFromFieldName(cellDataGridContext, draggedOverDescription.FieldName, alignment);
            }

            ColumnBase column = cell.ParentColumn;

            if (column != null)
            {
                GroupingHelper.AddNewGroupFromColumn(column, cellDataGridContext.Items.GroupDescriptions, newPos);
            }
        }
Пример #2
0
        public static void AddNewGroupFromColumnManagerCell(ColumnManagerCell cell, GroupLevelDescription draggedOverDescription, DropMarkAlignment alignment, DataGridControl parentDataGridControl)
        {
            if (cell == null)
            {
                return;
            }

            DataGridContext dataGridContext = DataGridControl.GetDataGridContext(cell);
            ColumnBase      column          = cell.ParentColumn;

            if ((dataGridContext == null) ||
                (parentDataGridControl == null) ||
                (column == null) ||
                (parentDataGridControl != dataGridContext.DataGridControl))
            {
                return;
            }

            var addGroupCommand = dataGridContext.AddGroupCommand;

            if (draggedOverDescription != null)
            {
                var position = GroupingHelper.GetGroupDescriptionIndexFromFieldName(dataGridContext, draggedOverDescription.FieldName, alignment);

                if (addGroupCommand.CanExecute(column, position))
                {
                    addGroupCommand.Execute(column, position);
                }
            }
            else
            {
                if (addGroupCommand.CanExecute(column))
                {
                    addGroupCommand.Execute(column);
                }
            }
        }