Completed
Last Updated: 12 Jun 2020 16:00 by ADMIN
Release R2 2020 SP1
Marianne
Created on: 26 May 2020 06:23
Category: VirtualGrid
Type: Bug Report
0
RadVirtualGrid: filter button's context menu is not properly replaced from the ContextMenuOpening event

Please use the following code snippet and click the filter button for the first column in the virtual grid. You will notice that the default menu is shown:

        RadContextMenu menu = new RadContextMenu();
        public RadForm1()
        {
            InitializeComponent();
            RadDateTimePicker aDateTimePicker = new RadDateTimePicker();
            RadMenuItem theMenuItem = new RadMenuItem();
            theMenuItem.MinSize = new Size(200, 30);
            RadHostItem theHostItem = new RadHostItem(aDateTimePicker);
            theMenuItem.Children.Add(theHostItem); 
            menu.Items.Add(theMenuItem);
            this.radVirtualGrid1.RowCount = 50;
            this.radVirtualGrid1.ColumnCount = 5;
            this.radVirtualGrid1.CellValueNeeded+=radVirtualGrid1_CellValueNeeded;

            this.radVirtualGrid1.AllowFiltering = true;
            this.radVirtualGrid1.ContextMenuOpening+=radVirtualGrid1_ContextMenuOpening;
        }

        private void radVirtualGrid1_ContextMenuOpening(object sender, VirtualGridContextMenuOpeningEventArgs e)
        {
            int i;
            string theMenuItemText;

            if (e.RowIndex == -3 && e.ColumnIndex < 1)
            {
                e.ContextMenu = menu.DropDown; 
            }
        }

        private void radVirtualGrid1_CellValueNeeded(object sender, VirtualGridCellValueNeededEventArgs e)
        {
            e.Value = Guid.NewGuid().ToString();
        }

1 comment
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 26 May 2020 06:35

Hello, Marianne,

I confirm that it is an issue with RadVirtualGrid. The possible solution that I can suggest is to cancel showing the default context menu and show the custom one as follows: 

        VirtualGridFilterCellElement filterCell = null;
        private void RadVirtualGrid1_CellClick(object sender, VirtualGridCellElementEventArgs e)
        {
              filterCell = e.CellElement as VirtualGridFilterCellElement;
        }

        private void radVirtualGrid1_ContextMenuOpening(object sender, VirtualGridContextMenuOpeningEventArgs e)
        { 
            if (e.RowIndex == -3 && e.ColumnIndex < 1)
            {

                bool isRightToLeft = (this.radVirtualGrid1.RightToLeft == System.Windows.Forms.RightToLeft.Yes);
                Point location = (isRightToLeft) ? new Point(filterCell.FilterButton.Size.Width, filterCell.FilterButton.Size.Height) :
                                 new Point(0, filterCell.FilterButton.Size.Height);
                
                e.Cancel = true;
                menu.Show(filterCell.FilterButton,location, RadDirection.Down);
            } 
        }

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.