public object ProvideValue(CustomPropertyInfo customPropertyInfo, object context)
        {
            RadGridView gridView = context as RadGridView;

			switch (customPropertyInfo.Name)
			{
				case "Columns":
					{
						List<ColumnProxy> columnProxies = new List<ColumnProxy>();

						foreach (GridViewColumn column in gridView.Columns)
						{
							columnProxies.Add(new ColumnProxy()
							{
								UniqueName = column.UniqueName,
								Header = column.Header.ToString(),
								DisplayOrder = column.DisplayIndex,
								Width = column.Width,
							});
						}

						return columnProxies;
					}

				case "SortDescriptors":
					{
						List<SortDescriptorProxy> sortDescriptorProxies = new List<SortDescriptorProxy>();

						foreach (ColumnSortDescriptor descriptor in gridView.SortDescriptors)
						{
							sortDescriptorProxies.Add(new SortDescriptorProxy()
							{
								ColumnUniqueName = descriptor.Column.UniqueName,
								SortDirection = descriptor.SortDirection,
							});
						}

						return sortDescriptorProxies;
					}

				case "GroupDescriptors":
					{
						List<GroupDescriptorProxy> groupDescriptorProxies = new List<GroupDescriptorProxy>();

						foreach (ColumnGroupDescriptor descriotor in gridView.GroupDescriptors)
						{
							groupDescriptorProxies.Add(new GroupDescriptorProxy()
							{
								ColumnUniqueName = descriotor.Column.UniqueName,
								SortDirection = descriotor.SortDirection,
							});
						}

						return groupDescriptorProxies;
					}

				case "FilterDescriptors":
					{
						List<FilterSetting> filterSettings = new List<FilterSetting>();

						foreach (IColumnFilterDescriptor columnFilter in gridView.FilterDescriptors)
						{
							FilterSetting columnFilterSetting = new FilterSetting();

							columnFilterSetting.ColumnUniqueName = columnFilter.Column.UniqueName;

							columnFilterSetting.SelectedDistinctValues.AddRange(columnFilter.DistinctFilter.DistinctValues);

							if (columnFilter.FieldFilter.Filter1.IsActive)
							{
								columnFilterSetting.Filter1 = new FilterDescriptorProxy();
								columnFilterSetting.Filter1.Operator = columnFilter.FieldFilter.Filter1.Operator;
								columnFilterSetting.Filter1.Value = columnFilter.FieldFilter.Filter1.Value;
								columnFilterSetting.Filter1.IsCaseSensitive = columnFilter.FieldFilter.Filter1.IsCaseSensitive;
							}

							columnFilterSetting.FieldFilterLogicalOperator = columnFilter.FieldFilter.LogicalOperator;

							if (columnFilter.FieldFilter.Filter2.IsActive)
							{
								columnFilterSetting.Filter2 = new FilterDescriptorProxy();
								columnFilterSetting.Filter2.Operator = columnFilter.FieldFilter.Filter2.Operator;
								columnFilterSetting.Filter2.Value = columnFilter.FieldFilter.Filter2.Value;
								columnFilterSetting.Filter2.IsCaseSensitive = columnFilter.FieldFilter.Filter2.IsCaseSensitive;
							}

							filterSettings.Add(columnFilterSetting);
						}

						return filterSettings;
					}
			}

			return null;
        }
Esempio n. 2
0
        public object ProvideValue(CustomPropertyInfo customPropertyInfo, object context)
        {
            RadGridView gridView = context as RadGridView;

            switch (customPropertyInfo.Name)
            {
            case "Columns":
            {
                List <ColumnProxy> columnProxies = new List <ColumnProxy>();

                foreach (GridViewColumn column in gridView.Columns)
                {
                    columnProxies.Add(new ColumnProxy()
                        {
                            UniqueName   = column.UniqueName,
                            Header       = column.Header.ToString(),
                            DisplayOrder = column.DisplayIndex,
                            Width        = column.Width,
                        });
                }

                return(columnProxies);
            }

            case "SortDescriptors":
            {
                List <SortDescriptorProxy> sortDescriptorProxies = new List <SortDescriptorProxy>();

                foreach (ColumnSortDescriptor descriptor in gridView.SortDescriptors)
                {
                    sortDescriptorProxies.Add(new SortDescriptorProxy()
                        {
                            ColumnUniqueName = descriptor.Column.UniqueName,
                            SortDirection    = descriptor.SortDirection,
                        });
                }

                return(sortDescriptorProxies);
            }

            case "GroupDescriptors":
            {
                List <GroupDescriptorProxy> groupDescriptorProxies = new List <GroupDescriptorProxy>();

                foreach (ColumnGroupDescriptor descriotor in gridView.GroupDescriptors)
                {
                    groupDescriptorProxies.Add(new GroupDescriptorProxy()
                        {
                            ColumnUniqueName = descriotor.Column.UniqueName,
                            SortDirection    = descriotor.SortDirection,
                        });
                }

                return(groupDescriptorProxies);
            }

            case "FilterDescriptors":
            {
                List <FilterSetting> filterSettings = new List <FilterSetting>();

                foreach (IColumnFilterDescriptor columnFilter in gridView.FilterDescriptors)
                {
                    FilterSetting columnFilterSetting = new FilterSetting();

                    columnFilterSetting.ColumnUniqueName = columnFilter.Column.UniqueName;

                    columnFilterSetting.SelectedDistinctValues.AddRange(columnFilter.DistinctFilter.DistinctValues);

                    if (columnFilter.FieldFilter.Filter1.IsActive)
                    {
                        columnFilterSetting.Filter1                 = new FilterDescriptorProxy();
                        columnFilterSetting.Filter1.Operator        = columnFilter.FieldFilter.Filter1.Operator;
                        columnFilterSetting.Filter1.Value           = columnFilter.FieldFilter.Filter1.Value;
                        columnFilterSetting.Filter1.IsCaseSensitive = columnFilter.FieldFilter.Filter1.IsCaseSensitive;
                    }

                    columnFilterSetting.FieldFilterLogicalOperator = columnFilter.FieldFilter.LogicalOperator;

                    if (columnFilter.FieldFilter.Filter2.IsActive)
                    {
                        columnFilterSetting.Filter2                 = new FilterDescriptorProxy();
                        columnFilterSetting.Filter2.Operator        = columnFilter.FieldFilter.Filter2.Operator;
                        columnFilterSetting.Filter2.Value           = columnFilter.FieldFilter.Filter2.Value;
                        columnFilterSetting.Filter2.IsCaseSensitive = columnFilter.FieldFilter.Filter2.IsCaseSensitive;
                    }

                    filterSettings.Add(columnFilterSetting);
                }

                return(filterSettings);
            }
            }

            return(null);
        }