예제 #1
0
        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));
        }
예제 #2
0
        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);
            }
        }
예제 #3
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));
        }