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

Hide Filter for some columns

10 Answers 422 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Omesis
Top achievements
Rank 1
Omesis asked on 02 Jun 2008, 08:49 PM
Hi I'm using a RadGridView, i want use a filter but not for all columns, how can i hide this for someone columns? Thanks

10 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 03 Jun 2008, 01:30 PM
Hi Alejandro,

Currently, showing and hiding the filtering editor box for separate columns is not supported by RadGridView. We will consider implementing this feature in one of our upcoming releases.

If you have additional questions, do not hesitate to contact me.

Regards,
Nikolay
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
luca
Top achievements
Rank 2
answered on 02 Feb 2010, 11:27 AM
i've the same problem. on ver. 2009 Q3, there is a solution?

Thanks
0
Nikolay
Telerik team
answered on 05 Feb 2010, 11:20 AM
Hi luca,

We introduced the ViewCellFormatting event which allows you to modify the non-data cells of RadGridView. So, in order to hide the filtering cells for some columns, you can use the following code pattern:
void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{            
    if (e.CellElement is GridFilterCellElement)
    {               
        // sample condition
        if (e.CellElement.ColumnInfo is GridViewTextBoxColumn)
        {
            e.CellElement.Visibility = ElementVisibility.Collapsed;
        }
    }
}


If you have additional questions, feel free to contact me.

Best wishes,
Nikolay
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Basel Nimer
Top achievements
Rank 2
answered on 23 Apr 2010, 10:30 PM
I do :)

i need to be able to remove some of the filters that appear, and add some others.

the idea is, i have a date (actually, i am saving that as an interger in the database, but doing formatting before binding), but i want to be able to let the user choose Today, or this WEEK to filter this columns, and that's it, no contains, no startswith, nothing more., how can i control that?

0
Nikolay
Telerik team
answered on 03 May 2010, 04:05 PM
Hello Basel Nimer,

You can modify the default filtering context menu by handling the ContextMenuOpening event:
http://www.telerik.com/help/winforms/modifying_existing_context_menu.html

Depending on your scenario, you also may need to prevent the user from entering a value in the filtering cell:
private void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
{
    if (this.radGridView1.CurrentRow is GridViewFilteringRowInfo)
    {
        if (((Telerik.WinControls.UI.GridViewDataColumn)this.radGridView1.CurrentColumn).FieldName == "HireDate")
        {
            e.Cancel = true;
        }
    }
}

Last, but not least, you should customize the filtering behavior on Click of the custom filerting menu items. To do this, you need to handle the CustomFiltering event. I am attaching a sample project that demonstrates the full approach.

If you need additional assistance, feel free to contact me.

Sincerely yours,
Nikolay
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
jprian
Top achievements
Rank 1
answered on 29 Jul 2011, 08:57 AM
Hi,
we are having one problem with this solution. If you select one data row and then click on filter icon, if you try
if (this.radGridView1.CurrentRow is GridViewFilteringRowInfo)

you get currentrow type is not GridViewFilteringRowInfo else GridViewDataRowInfo.
So you need before select row filter.
Is there other solution to get row type parent of ContextMenu?

Thanks
0
Nikolay
Telerik team
answered on 03 Aug 2011, 09:59 AM
Hello Jesus,

Thank you for pointing this out.

I have updated my project to work with the latest RadGridView API. The issue in question is also addressed there and you do not need to click on the filtering row in order to get the custom filter menu.

I hope this helps.

Kind regards,
Nikolay
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0
jprian
Top achievements
Rank 1
answered on 15 Aug 2011, 10:02 PM
Hello Nikolay, I guess that I didn't explain myself clearly. The issue is when I open context menu with right click on row filter I can't distinguish if click is on filter row or data row to show one or another menu option.
Thanks
0
Nikolay
Telerik team
answered on 16 Aug 2011, 09:11 AM
Hello Jprian,

Thank you for clarifying your requirement.

You can determine if you have right-clicked on a filter cell by checking the type of the ContextMenuProvider as in the example below:

void radGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
       {
           if (e.ContextMenuProvider is GridFilterCellElement)
           {
               // TO DO
               e.ContextMenu.Items.RemoveAt(0);
               e.ContextMenu.Items.RemoveAt(0);
               return;
           }
       }

I hope this helps.

All the best,
Nikolay
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
jprian
Top achievements
Rank 1
answered on 16 Aug 2011, 02:20 PM
Thanks Nicolay, your suggestion works perfectly.

Thanks again.
Tags
GridView
Asked by
Omesis
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
luca
Top achievements
Rank 2
Basel Nimer
Top achievements
Rank 2
jprian
Top achievements
Rank 1
Share this question
or