Rad grid view custom filter dialog

14 posts, 1 answers
  1. pulkit jain
    pulkit jain avatar
    11 posts
    Member since:
    Apr 2010

    Posted 21 May 2010 Link to this post

    Hello

    I have an query that how can i customize Rad grid view custom filter dialog box.
    Like mun text and all.

    Thanks & regards
    Pulkit Jain
  2. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 21 May 2010 Link to this post

    Hello pulkit jain,
     

    Currently it is not possible to replace this dialog. However you can add your own dialog by handling ContextMenuOpening event and adding a new menu item. We plan to extend the filtering functionality and the feature will be available in one of our upcoming releases.

    Best wishes,
    Jack
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. pulkit jain
    pulkit jain avatar
    11 posts
    Member since:
    Apr 2010

    Posted 25 May 2010 Link to this post

    Hello Jack


    Can we remove the menuitem for custom filtering?
    Can we only cusomize the name of the custom filter dialogbox?



    Thanks & regards
    Pulkit Jain
  5. Answer
    Jack
    Admin
    Jack avatar
    2333 posts

    Posted 27 May 2010 Link to this post

    Hello pulkit jain,

    Regarding your questions:

    1. Yes, you can remove it by handling ContextMenuOpening event. Here is a sample:

    void radGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
    {
        if (e.ContextMenuProvider == null)
        {
            e.ContextMenu.Items.RemoveAt(e.ContextMenu.Items.Count - 1);
        }
    }

    2. You have to create a custom cell element to rename the custom filtering form. Please consider the code below:
    void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e)
    {
        if (e.CellType == typeof(GridFilterCellElement))
        {
            e.CellType = typeof(MyFilterCell);
        }
    }
     
    public class MyFilterCell : GridFilterCellElement
    {
        public MyFilterCell(GridViewDataColumn column, GridRowElement row)
            : base(column, row)
        {
        }
     
        protected override Type ThemeEffectiveType
        {
            get { return typeof(GridFilterCellElement); }
        }
     
        protected override CompositeFilterForm CreateCompositeFilterForm()
        {
            CompositeFilterForm form = base.CreateCompositeFilterForm();
            form.Text = "My Filter form";
            return form;
        }
    }

    I hope this helps.

    Regards,
    Jack
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  6. racovita
    racovita avatar
    1 posts
    Member since:
    Oct 2010

    Posted 23 Nov 2010 Link to this post

    I have the same problem.I want to change the text and theme but GridFilterCellElement does not contain a method CreateCompositeFilterForm().
    Error 1 'Telerik.WinControls.UI.GridFilterCellElement' does not contain a definition for 'CreateCompositeFilterForm' D:\proiecte\vs2010\WinG\WinG\Nomen\Produse\List\WNProduseList.cs 52 49 WinG


  7. Svett
    Admin
    Svett avatar
    728 posts

    Posted 26 Nov 2010 Link to this post

    Hello racovita,

    Thank you for your report.

    The method CreateCompositeFilterForm that my colleague uses to replace the default composite form is not public in the latest version. It will be available in the upcoming version Q3 2010 SP1.

    Kind regards,
    Svett
    the Telerik team
    Get started with RadControls for WinForms with numerous videos and detailed documentation.
  8. Dave Galligher
    Dave Galligher avatar
    37 posts
    Member since:
    May 2010

    Posted 13 Jan 2011 Link to this post

    WINFORMS QUESTION: In regards to the Filter context menus, I have an issue where the number of items in the menu don't really apply and is creating confusion for our end user - Columns based on GridViewCheckBoxColumn. The context menu comes back with 6 options: No Filter, Equals, Not Equal To, Is Null, Is Not Null, Custom. Our users only need the first two since the ThreeState property of the column is set to False. Each one of the columns on the grid has a name attached to it. In my instance the ColumnName is "Annual" but it could be anything.

    The problem is the CurrentColumn.Name of the RadGridview doesn't change unless the user physically selects the cell in the column below the filter row or the text box for the filter and in the instance of 'No Filter' this is not abundantly transparent to the user to click there, if they immediately select the filter button for a column without selecting a cell in the column -- it is set to whatever the last column was that they had clicked on regardless of what button for the filter they clicked on. In my example, I need to remove all but two of the menus on the context menu for the filter - not just the Custom option. Other columns on the grid (over 320 of them and various types) require the default menus provided my Telerik.

    I have solved the problem by this block of code, but it seems like a hack and I know later on this could lead to additional problems:

    // HACK: This will not work in all instances but it fixes the problem Design had with the menu
                    // having values that don't make sense based on the grid.
                    if (e.ContextMenu.Items.Count == 6)
                    {
                        string currentColumn = radGridView.CurrentColumn.Name;                     // sanity check to prove current column name is bogus

                        int minValue = e.ContextMenu.Items.Count - 5;
                        for (int x = e.ContextMenu.Items.Count - 1; x > minValue; x--)
                            e.ContextMenu.Items.RemoveAt(x);
                    }

    I'm thinking there should be a better way other than what is coded? Eventually, I may hit a menu that has six items that I don't want to pull those items from, in other words it should be specific based on the column name that originally triggers this, code that had to be commented out:

                   // you would think it would work like this but unless the user actuall clicks
                    // on the column the button column does not calibrate to the column the filter
                    // button resides in - I'll turn in an error to telerik
                    
                    /*
                    string currentColumnName = radGridView.CurrentColumn.Name;
                    if (currentColumnName == ColumnNameDictionary[BudgetColumnTypes.Annual])
                    {
                        int minValue = e.ContextMenu.Items.Count - 5;
                        for (int x = e.ContextMenu.Items.Count - 1; x > minValue; x--)
                            e.ContextMenu.Items.RemoveAt(x);
                    }
                     */



    Also, while on the subject of the filter row, is there a way to change the forecolor of the labels that appear in front of the textbox that appears on row. The light blue or cadet blue is really faint, hard to see, for a lot of our users and is creating an additional problem.

    Thank you.




  9. Svett
    Admin
    Svett avatar
    728 posts

    Posted 18 Jan 2011 Link to this post

    Hi Dave Galligher,

    You can change the context menu of the filter cell by using the following code snippet:

    void radGridView1_ContextMenuOpening(object sender, Telerik.WinControls.UI.ContextMenuOpeningEventArgs e)
    {
        BaseGridBehavior gridBehavior = this.radGridView1.GridBehavior as BaseGridBehavior;
        GridFilterCellElement filterCell = gridBehavior.CellAtPoint as GridFilterCellElement;
     
        if (e.ContextMenuProvider == null && filterCell != null)
        {
            if (filterCell.ColumnInfo.Name == "YourColumn")
            {
                // Remove the items from the context menu
            }
        }
    }

    If you want to change the color of the text in the GridFilterCellElement, you should use the ViewCellFormatting event:
    void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
    {
        GridFilterCellElement filterCell = e.CellElement as GridFilterCellElement;
     
        if (filterCell != null)
        {
            filterCell.FilterOperatorText.ForeColor = Color.Red;
        }
    }

    Notice that all code snippets above are for Q3 2010 SP1.

    Greetings,
    Svett
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
  10. Dave Galligher
    Dave Galligher avatar
    37 posts
    Member since:
    May 2010

    Posted 18 Jan 2011 Link to this post

    Thank you, that worked.
  11. Andrew
    Andrew avatar
    8 posts
    Member since:
    Sep 2010

    Posted 15 Feb 2011 Link to this post

    Hello Jack

    I too just want to change the text of the custom dialog form.

    I tried the following code as suggested.
    void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e)
    {
        if (e.CellType == typeof(GridFilterCellElement))
        {
            e.CellType = typeof(MyFilterCell);
        }
    }
     
    public class MyFilterCell : GridFilterCellElement
    {
        public MyFilterCell(GridViewDataColumn column, GridRowElement row)
            : base(column, row)
        {
        }
     
        protected override Type ThemeEffectiveType
        {
            get { return typeof(GridFilterCellElement); }
        }
     
        protected override CompositeFilterForm CreateCompositeFilterForm()
        {
            CompositeFilterForm form = base.CreateCompositeFilterForm();
            form.Text = "My Filter form";
            return form;
        }
    }

    However the dialog text still default back to the default text.
    See attached png


    Am I doing something incorrectly?
    I am using the laster version.
    I can see the form.text is being changed as per above 9via debug) but the custom text gets overwritten again

    Thanks
    Andrew
  12. Svett
    Admin
    Svett avatar
    728 posts

    Posted 18 Feb 2011 Link to this post

    Hi Andrew,

    In Q3 2010 SP1 (v2010.3 10.1215) you should create a custom filter form, where you should override the Initialize method:

    public class CustomCompositeFilterForm : CompositeFilterForm
    {
        public override void Initialize(GridViewDataColumn dataColumn, FilterDescriptor filterDescriptor, bool useTypedEditors)
        {
            base.Initialize(dataColumn, filterDescriptor, useTypedEditors);
            this.Text = "Your text Here";
        }
    }

    Best wishes,
    Svett
    the Telerik team
  13. Andrew
    Andrew avatar
    8 posts
    Member since:
    Sep 2010

    Posted 18 Feb 2011 Link to this post

    Thank you Svett for your quick reply.

    I will let you know if I have any problems.

    Regards
    Andrew
  14. Jason
    Jason avatar
    11 posts
    Member since:
    May 2008

    Posted 25 Jul 2012 Link to this post

    I believe the code used in scenario 1 is incorrect. I believe you want != null instead of == null.

    void radGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
    {
        if (e.ContextMenuProvider == null) //should be != null
        {
            e.ContextMenu.Items.RemoveAt(e.ContextMenu.Items.Count - 1);
        }
    }

  15. Svett
    Admin
    Svett avatar
    728 posts

    Posted 27 Jul 2012 Link to this post

    Hi Jason,

    In previous versions, the ContextMenuProvider property of the event arguments was null, when the event occurs for GridFilterCellElement.

    However, we have changed this behavior and for recent versions of our suite, your suggestion is valid.

    Greetings,
    Svett
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready