protected virtual RadDropDownMenu CreateFilterMenu()
        {
            System.Type dataType = this.ViewInfo.GetColumnDataType(this.ColumnIndex);
            if ((object)dataType == null)
            {
                dataType = typeof(string);
            }
            CompositeFilterDescriptor descriptor = this.Descriptor as CompositeFilterDescriptor;
            int             descriptorType       = (int)CompositeFilterDescriptor.GetDescriptorType(descriptor);
            RadDropDownMenu radDropDownMenu      = new RadDropDownMenu();

            foreach (FilterOperationContext filterOperation in FilterOperationContext.GetFilterOperations(dataType))
            {
                RadFilterOperationMenuItem operationMenuItem = new RadFilterOperationMenuItem(filterOperation);
                operationMenuItem.IsChecked = descriptor == null && operationMenuItem.Operator == this.SelectedFilterOperator;
                operationMenuItem.Click    += new EventHandler(this.FilterMenuItem_Click);
                operationMenuItem.Text      = LocalizationProvider <RadVirtualGridLocalizationProvider> .CurrentProvider.GetLocalizedString(filterOperation.id);

                radDropDownMenu.Items.Add((RadItem)operationMenuItem);
            }
            radDropDownMenu.PopupOpening += new RadPopupOpeningEventHandler(this.contextMenu_PopupOpening);
            radDropDownMenu.PopupClosed  += new RadPopupClosedEventHandler(this.contextMenu_PopupClosed);
            this.InitializeMenuItemsText();
            return(radDropDownMenu);
        }
Пример #2
0
        protected virtual RadDropDownMenu CreateFilterMenu(System.Type dataType)
        {
            FilterDescriptor          descriptor       = this.Descriptor;
            CompositeFilterDescriptor filterDescriptor = descriptor as CompositeFilterDescriptor;

            CompositeFilterDescriptor.DescriptorType descriptorType = CompositeFilterDescriptor.GetDescriptorType(filterDescriptor);
            RadDropDownMenu menu = new RadDropDownMenu();
            List <FilterOperationContext> filterOperations = FilterOperationContext.GetFilterOperations(dataType);
            bool flag = this.ColumnInfo is GridViewMultiComboBoxColumn;

            foreach (FilterOperationContext context in filterOperations)
            {
                if (!flag || context.Operator == FilterOperator.None || (context.Operator == FilterOperator.IsEqualTo || context.Operator == FilterOperator.IsNotEqualTo))
                {
                    RadFilterOperationMenuItem operationMenuItem = new RadFilterOperationMenuItem(context);
                    operationMenuItem.IsChecked = filterDescriptor == null && operationMenuItem.Operator == descriptor.Operator;
                    operationMenuItem.Click    += new EventHandler(this.FilterMenuItem_Click);
                    menu.Items.Add((RadItem)operationMenuItem);
                }
            }
            if (GridViewHelper.IsNumeric(dataType) || (object)dataType == (object)typeof(DateTime))
            {
                RadFilterComposeMenuItem filterComposeMenuItem1 = new RadFilterComposeMenuItem("FilterFunctionsBetween");
                filterComposeMenuItem1.IsChecked        = filterDescriptor != null && descriptorType == CompositeFilterDescriptor.DescriptorType.Between;
                filterComposeMenuItem1.FilterDescriptor = (FilterDescriptor)this.GetCompositeFilterDescriptor(CompositeFilterDescriptor.DescriptorType.Between, filterDescriptor, dataType);
                filterComposeMenuItem1.Click           += new EventHandler(this.FilterMenuItem_Click);
                menu.Items.Add((RadItem)filterComposeMenuItem1);
                RadFilterComposeMenuItem filterComposeMenuItem2 = new RadFilterComposeMenuItem("FilterFunctionNotBetween");
                filterComposeMenuItem2.IsChecked        = descriptorType == CompositeFilterDescriptor.DescriptorType.NotBetween;
                filterComposeMenuItem2.FilterDescriptor = (FilterDescriptor)this.GetCompositeFilterDescriptor(CompositeFilterDescriptor.DescriptorType.NotBetween, filterDescriptor, dataType);
                filterComposeMenuItem2.Click           += new EventHandler(this.FilterMenuItem_Click);
                menu.Items.Add((RadItem)filterComposeMenuItem2);
            }
            if ((object)dataType != (object)typeof(Image))
            {
                RadFilterComposeMenuItem filterComposeMenuItem = new RadFilterComposeMenuItem("FilterFunctionsCustom");
                filterComposeMenuItem.FilterDescriptor = descriptor.Clone() as FilterDescriptor;
                filterComposeMenuItem.Click           += new EventHandler(this.FilterMenuItem_Click);
                filterComposeMenuItem.IsChecked        = filterDescriptor != null && descriptorType == CompositeFilterDescriptor.DescriptorType.Unknown;
                menu.Items.Add((RadItem)filterComposeMenuItem);
            }
            menu.PopupOpening += new RadPopupOpeningEventHandler(this.contextMenu_PopupOpening);
            menu.PopupClosed  += new RadPopupClosedEventHandler(this.contextMenu_PopupClosed);
            GridViewContextMenuManager.UpdateMenuTheme((GridVisualElement)this.GridViewElement, menu);
            return(menu);
        }
Пример #3
0
 private void PrepareDropDownLists(
     RadDropDownList radDropDownList,
     FilterOperator filterOperator)
 {
     if (this.filterOperationContext == null)
     {
         this.filterOperationContext = FilterOperationContext.GetFilterOperations(this.DataType);
     }
     for (int index = 0; index < this.filterOperationContext.Count; ++index)
     {
         FilterOperationContext operationContext = this.filterOperationContext[index];
         RadListDataItem        radListDataItem  = new RadListDataItem();
         radListDataItem.Text  = operationContext.Name;
         radListDataItem.Value = (object)operationContext.Operator;
         radDropDownList.Items.Add(radListDataItem);
         if (operationContext.Operator == filterOperator)
         {
             radDropDownList.SelectedItem = radListDataItem;
         }
     }
     radDropDownList.SelectedIndexChanged += new Telerik.WinControls.UI.Data.PositionChangedEventHandler(this.RadDropDownList_SelectedIndexChanged);
 }
Пример #4
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);
        }
Пример #5
0
 public RadFilterOperationMenuItem(FilterOperationContext context)
     : base(context.Name)
 {
     this.context = context;
 }