This is a migrated thread and some comments may be shown as answers.

Rad grid view custom filter dialog

13 Answers 529 Views
GridView
This is a migrated thread and some comments may be shown as answers.
pulkit jain
Top achievements
Rank 1
pulkit jain asked on 21 May 2010, 10:30 AM
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

13 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 21 May 2010, 02:11 PM
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.
0
pulkit jain
Top achievements
Rank 1
answered on 25 May 2010, 04:47 PM
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
0
Accepted
Jack
Telerik team
answered on 27 May 2010, 04:32 PM
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.
0
racovita
Top achievements
Rank 1
answered on 23 Nov 2010, 03:04 PM
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


0
Svett
Telerik team
answered on 26 Nov 2010, 09:51 AM
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.
0
Dave Galligher
Top achievements
Rank 2
answered on 13 Jan 2011, 11:13 PM
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.




0
Svett
Telerik team
answered on 18 Jan 2011, 05:52 PM
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.
0
Dave Galligher
Top achievements
Rank 2
answered on 18 Jan 2011, 09:15 PM
Thank you, that worked.
0
Andrew
Top achievements
Rank 1
Iron
answered on 16 Feb 2011, 01:01 AM
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
0
Svett
Telerik team
answered on 18 Feb 2011, 08:49 AM
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
0
Andrew
Top achievements
Rank 1
Iron
answered on 18 Feb 2011, 11:32 AM
Thank you Svett for your quick reply.

I will let you know if I have any problems.

Regards
Andrew
0
Jason
Top achievements
Rank 1
answered on 25 Jul 2012, 02:43 PM
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);
    }
}

0
Svett
Telerik team
answered on 27 Jul 2012, 02:11 PM
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 >>
Tags
GridView
Asked by
pulkit jain
Top achievements
Rank 1
Answers by
Jack
Telerik team
pulkit jain
Top achievements
Rank 1
racovita
Top achievements
Rank 1
Svett
Telerik team
Dave Galligher
Top achievements
Rank 2
Andrew
Top achievements
Rank 1
Iron
Jason
Top achievements
Rank 1
Share this question
or