예제 #1
0
        public override void InitializeEditor(IInputEditor editor)
        {
            GridSpinEditor gridSpinEditor = editor as GridSpinEditor;

            if (gridSpinEditor == null)
            {
                return;
            }
            RadSpinElement editorElement = (RadSpinElement)gridSpinEditor.EditorElement;

            editorElement.DecimalPlaces     = GridViewHelper.IsInteger(this.DataType) || GridViewHelper.IsIntegerSql(this.DataType) ? 0 : this.DecimalPlaces;
            gridSpinEditor.ValueType        = this.DataType;
            editorElement.ShowUpDownButtons = this.ShowUpDownButtons;
            editorElement.Step               = this.Step;
            editorElement.MinValue           = this.Minimum;
            editorElement.MaxValue           = this.Maximum;
            editorElement.ThousandsSeparator = this.ThousandsSeparator;
        }
예제 #2
0
 public static bool ContainsInnerDescriptor(
     PropertyDescriptorCollection descriptors,
     string fieldName)
 {
     return(GridViewHelper.FindSubPropertyDescriptor(descriptors, fieldName) != null);
 }
예제 #3
0
        protected virtual void CreateFilterOperationsMenuItems()
        {
            FilterDescriptor          filterDescriptor1 = this.GetFilterDescriptor();
            CompositeFilterDescriptor filterDescriptor2 = filterDescriptor1 as CompositeFilterDescriptor;

            CompositeFilterDescriptor.DescriptorType descriptorType = CompositeFilterDescriptor.GetDescriptorType(filterDescriptor2);
            RadMenuItem radMenuItem = new RadMenuItem();

            radMenuItem.IsChecked = false;
            radMenuItem.Text      = LocalizationProvider <RadGridLocalizationProvider> .CurrentProvider.GetLocalizedString("FilterMenuAvailableFilters");

            radMenuItem.StretchVertically = false;
            this.Items.Add((RadItem)radMenuItem);
            RadMenuSeparatorItem menuSeparatorItem = new RadMenuSeparatorItem();

            menuSeparatorItem.StretchVertically = false;
            this.Items.Add((RadItem)menuSeparatorItem);
            System.Type filteringDataType = this.ColumnFilteringDataType;
            foreach (FilterOperationContext filterOperation in FilterOperationContext.GetFilterOperations(filteringDataType))
            {
                if (filterOperation.Operator == FilterOperator.None || filterOperation.Operator == FilterOperator.IsNull || filterOperation.Operator == FilterOperator.IsNotNull)
                {
                    RadFilterOperationMenuItem operationMenuItem = new RadFilterOperationMenuItem(filterOperation);
                    operationMenuItem.Click += new EventHandler(this.FilterMenuItem_Click);
                    if (filterOperation.Operator == FilterOperator.None)
                    {
                        operationMenuItem.Enabled = filterDescriptor2 != null && filterDescriptor2.Operator != FilterOperator.None || operationMenuItem.Operator != filterDescriptor1.Operator;
                        operationMenuItem.Text    = LocalizationProvider <RadGridLocalizationProvider> .CurrentProvider.GetLocalizedString("FilterMenuClearFilters");

                        operationMenuItem.Image             = (Image)Resources.ClearFilter;
                        operationMenuItem.TextImageRelation = TextImageRelation.ImageBeforeText;
                        operationMenuItem.ImageAlignment    = ContentAlignment.MiddleLeft;
                        operationMenuItem.DisplayStyle      = DisplayStyle.ImageAndText;
                        this.Items.Insert(0, (RadItem)operationMenuItem);
                    }
                    else
                    {
                        operationMenuItem.IsChecked = (filterDescriptor2 == null || filterDescriptor2.Operator == FilterOperator.None) && operationMenuItem.Operator == filterDescriptor1.Operator;
                        if (operationMenuItem.IsChecked)
                        {
                            radMenuItem.IsChecked = true;
                        }
                        radMenuItem.Items.Add((RadItem)operationMenuItem);
                    }
                }
                else
                {
                    RadFilterComposeMenuItem filterComposeMenuItem = new RadFilterComposeMenuItem();
                    filterComposeMenuItem.Text                      = filterOperation.Name;
                    filterComposeMenuItem.FilterDescriptor          = filterDescriptor1.Clone() as FilterDescriptor;
                    filterComposeMenuItem.FilterDescriptor.Operator = filterOperation.Operator;
                    filterComposeMenuItem.Click                    += new EventHandler(this.FilterMenuItem_Click);
                    filterComposeMenuItem.IsChecked                 = (filterDescriptor2 == null || filterDescriptor2.Operator == FilterOperator.None) && filterOperation.Operator == filterDescriptor1.Operator;
                    if (filterComposeMenuItem.IsChecked)
                    {
                        radMenuItem.IsChecked = true;
                    }
                    radMenuItem.Items.Add((RadItem)filterComposeMenuItem);
                }
            }
            if (GridViewHelper.IsNumeric(filteringDataType) || (object)filteringDataType == (object)typeof(DateTime))
            {
                RadFilterComposeMenuItem filterComposeMenuItem1 = new RadFilterComposeMenuItem("FilterFunctionsBetween");
                filterComposeMenuItem1.IsChecked = filterDescriptor2 != null && filterDescriptor2.Operator != FilterOperator.None && descriptorType == CompositeFilterDescriptor.DescriptorType.Between;
                if (filterComposeMenuItem1.IsChecked)
                {
                    radMenuItem.IsChecked = true;
                }
                filterComposeMenuItem1.FilterDescriptor = (FilterDescriptor)this.GetCompositeFilterDescriptor(CompositeFilterDescriptor.DescriptorType.Between, filterDescriptor2);
                filterComposeMenuItem1.Click           += new EventHandler(this.FilterMenuItem_Click);
                radMenuItem.Items.Add((RadItem)filterComposeMenuItem1);
                RadFilterComposeMenuItem filterComposeMenuItem2 = new RadFilterComposeMenuItem("FilterFunctionNotBetween");
                filterComposeMenuItem2.IsChecked = descriptorType == CompositeFilterDescriptor.DescriptorType.NotBetween;
                if (filterComposeMenuItem2.IsChecked)
                {
                    radMenuItem.IsChecked = true;
                }
                filterComposeMenuItem2.FilterDescriptor = (FilterDescriptor)this.GetCompositeFilterDescriptor(CompositeFilterDescriptor.DescriptorType.NotBetween, filterDescriptor2);
                filterComposeMenuItem2.Click           += new EventHandler(this.FilterMenuItem_Click);
                radMenuItem.Items.Add((RadItem)filterComposeMenuItem2);
            }
            if ((object)filteringDataType == (object)typeof(Image))
            {
                return;
            }
            RadFilterComposeMenuItem filterComposeMenuItem3 = new RadFilterComposeMenuItem("FilterFunctionsCustom");

            filterComposeMenuItem3.FilterDescriptor = filterDescriptor1.Clone() as FilterDescriptor;
            filterComposeMenuItem3.Click           += new EventHandler(this.FilterMenuItem_Click);
            filterComposeMenuItem3.IsChecked        = filterDescriptor2 != null && filterDescriptor2.Operator != FilterOperator.None && descriptorType == CompositeFilterDescriptor.DescriptorType.Unknown;
            if (filterComposeMenuItem3.IsChecked)
            {
                radMenuItem.IsChecked = true;
            }
            radMenuItem.Items.Add((RadItem)filterComposeMenuItem3);
        }
예제 #4
0
        public bool Sort(RadSortOrder sortOrder, bool multiSortMode)
        {
            if (!this.CanSort || this.ownerTemplate == null)
            {
                return(false);
            }
            SortDescriptor           descriptor      = new SortDescriptor(this.Name, GridViewHelper.GetSortDirection(sortOrder));
            SortDescriptorCollection sortDescriptors = this.ownerTemplate.SortDescriptors;
            bool flag = !multiSortMode && sortDescriptors.Count > 1;

            if (flag)
            {
                if (sortOrder == RadSortOrder.None)
                {
                    descriptor = (SortDescriptor)null;
                }
                if (this.RaiseSortingChanging(descriptor))
                {
                    return(false);
                }
                sortDescriptors.BeginUpdate();
                sortDescriptors.Clear();
            }
            int index = sortDescriptors.IndexOf(this.Name);

            if (index >= 0)
            {
                if (sortOrder == RadSortOrder.None)
                {
                    sortDescriptors.RemoveAt(index);
                    return(true);
                }
                if (sortOrder == GridViewHelper.GetSortDirection(sortDescriptors[index].Direction))
                {
                    return(false);
                }
                sortDescriptors[index].Direction = GridViewHelper.GetSortDirection(sortOrder);
                return(true);
            }
            if (sortOrder == RadSortOrder.None)
            {
                if (flag)
                {
                    sortDescriptors.EndUpdate();
                }
                return(false);
            }
            if (!multiSortMode && sortDescriptors.Count == 1)
            {
                sortDescriptors[0] = descriptor;
            }
            else
            {
                sortDescriptors.Add(descriptor);
            }
            if (flag)
            {
                sortDescriptors.EndUpdate();
            }
            return(true);
        }