protected virtual void ExecuteCore(ColumnBase column, int index)
        {
            var groupDescriptions = this.GroupDescriptions;

            if (groupDescriptions == null)
            {
                return;
            }

            GroupDescription groupDescription = this.GetGroupDescription(column);

            if (groupDescription == null)
            {
                groupDescription = new DataGridGroupDescription(this.GetColumnName(column));
            }

            var dataGridGroupDescription = groupDescription as DataGridGroupDescription;

            if ((dataGridGroupDescription != null) && (dataGridGroupDescription.GroupConfiguration == null))
            {
                dataGridGroupDescription.GroupConfiguration = this.GetGroupConfiguration(column);
            }

            if (index < 0)
            {
                groupDescriptions.Add(groupDescription);
            }
            else
            {
                groupDescriptions.Insert(index, groupDescription);
            }
        }
        private IQueryable FilterQueryable(IQueryable queryable)
        {
            // Filters a queryable to match this Group's clause.
            // This method does not apply the AutoFilter clauses or the FilterRow clauses.
            // It is the DataGridVirtualizingQueryableCollectionViewGroupRoot's job to do so on the
            // base queryable used as a base for all other queryables.

            if (queryable == null)
            {
                throw new ArgumentNullException("queryable");
            }

            int level = this.Level;

            DataGridVirtualizingCollectionViewBase collectionView = this.GetCollectionView();

            ObservableCollection <GroupDescription> groupDescriptions = collectionView.GroupDescriptions;

            Debug.Assert((groupDescriptions != null) && (level < groupDescriptions.Count));

            DataGridGroupDescription groupBy = groupDescriptions[level] as DataGridGroupDescription;

            Debug.Assert(groupBy != null);

            ParameterExpression sharedParameterExpression = queryable.CreateParameterExpression();

            Expression expression = queryable.CreateEqualExpression(sharedParameterExpression, groupBy.PropertyName, this.Name);

            return(queryable.WhereFilter(sharedParameterExpression, expression));
        }
Exemple #3
0
        internal DataGridCollectionViewGroup GetGroup(
            RawItem rawItem,
            int level,
            CultureInfo culture,
            ObservableCollection <GroupDescription> groupByList,
            GroupSortComparer[] groupSortComparers)
        {
            // If sortComparers is null, we are in massive group creation, no order check.

            if (this.IsBottomLevel)
            {
                throw new InvalidOperationException("An attempt was made to get a group for which a GroupDescription has not been provided.");
            }

            object groupName = m_subGroupBy.GroupNameFromItem(rawItem.DataItem, level, culture);
            DataGridGroupDescription    dataGridGroupDescription = m_subGroupBy as DataGridGroupDescription;
            DataGridCollectionViewGroup group;

            if (dataGridGroupDescription != null)
            {
                group = m_groupsDictionary[DataGridCollectionViewGroup.GetHashKeyFromName(groupName)]
                        as DataGridCollectionViewGroup;
            }
            else
            {
                int itemCount = this.ItemCount;
                group = null;

                for (int i = 0; i < itemCount; i++)
                {
                    DataGridCollectionViewGroup tempGroup = this.ProtectedItems[i] as DataGridCollectionViewGroup;

                    if (m_subGroupBy.NamesMatch(tempGroup.Name, groupName))
                    {
                        group = tempGroup;
                        break;
                    }
                }
            }

            if (group == null)
            {
                group = this.CreateSubGroup(
                    groupName, level, groupByList, groupSortComparers);
            }

            return(group);
        }
Exemple #4
0
        public static void AddNewGroupFromColumn(ColumnBase column, ObservableCollection <GroupDescription> targetGroupDescriptions, int position)
        {
            GroupDescription groupDescription = column.GroupDescription;

            if (groupDescription == null)
            {
                groupDescription = new DataGridGroupDescription(column.FieldName);
            }

            DataGridGroupDescription dataGridGroupDescription = groupDescription as DataGridGroupDescription;

            if ((dataGridGroupDescription != null) && (dataGridGroupDescription.GroupConfiguration == null))
            {
                dataGridGroupDescription.GroupConfiguration = column.GroupConfiguration;
            }

            targetGroupDescriptions.Insert(position, groupDescription);
        }
Exemple #5
0
        internal static GroupConfiguration GetGroupConfiguration(DataGridContext dataGridContext, ObservableCollection <GroupDescription> groupDescriptions, GroupConfigurationSelector groupConfigSelector, int groupLevel, CollectionViewGroup collectionViewGroup)
        {
            if (dataGridContext == null)
            {
                throw new ArgumentNullException("dataGridContext");
            }

            if (groupDescriptions == null)
            {
                throw new ArgumentNullException("groupDescriptions");
            }

            if (groupLevel >= groupDescriptions.Count)
            {
                throw new ArgumentException("The specified group level is greater than the number of GroupDescriptions in the DataGridContext.", "groupLevel");
            }

            GroupDescription groupDescription = groupDescriptions[groupLevel];

            GroupConfiguration       retval = null;
            DataGridGroupDescription dataGridGroupDescription = groupDescription as DataGridGroupDescription;

            if ((dataGridGroupDescription != null) && (dataGridGroupDescription.GroupConfiguration != null))
            {
                retval = dataGridGroupDescription.GroupConfiguration;
            }
            else if (groupConfigSelector != null)
            {
                retval = groupConfigSelector.SelectGroupConfiguration(groupLevel, collectionViewGroup, groupDescription);
            }

            if (retval == null)
            {
                retval = dataGridContext.DefaultGroupConfiguration;
            }

            if (retval == null)
            {
                retval = GroupConfiguration.DefaultGroupConfiguration;
            }

            return(retval);
        }
        public override GroupConfiguration SelectGroupConfiguration(int groupLevel, CollectionViewGroup collectionViewGroup, System.ComponentModel.GroupDescription groupDescription)
        {
            if (m_groupConfigurationSelectorItems.Count == 0)
            {
                return(base.SelectGroupConfiguration(groupLevel, collectionViewGroup, groupDescription));
            }

            string fieldName = string.Empty;

            DataGridGroupDescription dataGridGroupDescription = groupDescription as DataGridGroupDescription;

            if (dataGridGroupDescription != null)
            {
                fieldName = dataGridGroupDescription.PropertyName;
            }
            else
            {
                PropertyGroupDescription propertyGroupDescription = groupDescription as PropertyGroupDescription;
                if (propertyGroupDescription != null)
                {
                    fieldName = propertyGroupDescription.PropertyName;
                }
            }

            if (String.IsNullOrEmpty(fieldName) == true)
            {
                return(base.SelectGroupConfiguration(groupLevel, collectionViewGroup, groupDescription));
            }

            FieldNameGroupConfigurationSelectorItem groupConfig = m_groupConfigurationSelectorItems.GetGroupConfigurationSelectorItem(fieldName);

            if (groupConfig != null)
            {
                return(groupConfig.GroupConfiguration);
            }

            return(base.SelectGroupConfiguration(groupLevel, collectionViewGroup, groupDescription));
        }
    protected virtual void ExecuteCore( ColumnBase column, int index )
    {
      var groupDescriptions = this.GroupDescriptions;
      if( groupDescriptions == null )
        return;

      GroupDescription groupDescription = this.GetGroupDescription( column );
      if( groupDescription == null )
      {
        groupDescription = new DataGridGroupDescription( this.GetColumnName( column ) );
      }

      var dataGridGroupDescription = groupDescription as DataGridGroupDescription;
      if( ( dataGridGroupDescription != null ) && ( dataGridGroupDescription.GroupConfiguration == null ) )
      {
        dataGridGroupDescription.GroupConfiguration = this.GetGroupConfiguration( column );
      }

      if( index < 0 )
      {
        groupDescriptions.Add( groupDescription );
      }
      else
      {
        groupDescriptions.Insert( index, groupDescription );
      }
    }
    public static void AddNewGroupFromColumn( ColumnBase column, ObservableCollection<GroupDescription> targetGroupDescriptions, int position )
    {
      GroupDescription groupDescription = column.GroupDescription;

      if( groupDescription == null )
        groupDescription = new DataGridGroupDescription( column.FieldName );

      DataGridGroupDescription dataGridGroupDescription = groupDescription as DataGridGroupDescription;

      if( ( dataGridGroupDescription != null ) && ( dataGridGroupDescription.GroupConfiguration == null ) )
        dataGridGroupDescription.GroupConfiguration = column.GroupConfiguration;

      targetGroupDescriptions.Insert( position, groupDescription );
    }