Hi,
I have a problem with GridView and Filtering. There is a submenu showing all available filters such as ("Contains", "Does not contain", "Starts with", etc.). Now I want to hide some of those entries for specific columns. I haven't found any examples solving my problem. Could anyone give me a hint or provide me some short example solving my problem?
Thx
I have a problem with GridView and Filtering. There is a submenu showing all available filters such as ("Contains", "Does not contain", "Starts with", etc.). Now I want to hide some of those entries for specific columns. I haven't found any examples solving my problem. Could anyone give me a hint or provide me some short example solving my problem?
Thx
5 Answers, 1 is accepted
0
Hello Georg,
Thank you for writing.
You can customize the context menu of the Excel-like filtering by using a custom header cell element and overriding the CreateFilteringDropDownMenu method. This will give you access to the menu items. Please consider the following code as an example:
Hope this helps. Let me know if you have any additional questions.
Kind regards,
Martin Vasilev
the Telerik team
Thank you for writing.
You can customize the context menu of the Excel-like filtering by using a custom header cell element and overriding the CreateFilteringDropDownMenu method. This will give you access to the menu items. Please consider the following code as an example:
{
void
radGridView1_CreateCell(
object
sender, GridViewCreateCellEventArgs e)
{
if
(e.CellType ==
typeof
(GridHeaderCellElement))
{
e.CellType =
typeof
(CustomHeaderCellElement);
}
}
}
public
class
CustomHeaderCellElement : GridHeaderCellElement
{
public
CustomHeaderCellElement(GridViewColumn column, GridRowElement row) :
base
(column, row) { }
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(GridHeaderCellElement);
}
}
protected
override
RadSizableDropDownMenu CreateFilteringDropDownMenu()
{
RadSizableDropDownMenu menu =
base
.CreateFilteringDropDownMenu();
((RadMenuItem)menu.Items[1]).Items[0].Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
return
menu;
}
}
Hope this helps. Let me know if you have any additional questions.
Kind regards,
Martin Vasilev
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!
0
webmaster
Top achievements
Rank 1
answered on 25 Nov 2011, 04:25 PM
I have a problem, I used the recommendation but I get the following error message
'Telerik.WinControls.UI.GridHeaderCellElement' no contiene una definición para 'CreateFilteringDropDownMenu'
I have the Q1 version
how I can fix it.
thanks
'Telerik.WinControls.UI.GridHeaderCellElement' no contiene una definición para 'CreateFilteringDropDownMenu'
I have the Q1 version
how I can fix it.
thanks
0
Hello Webmaster,
Svett
the Telerik team
The only way to use the supplied code snippet is by upgrading to the latest version Q3 2011 (2011.3.11.1116). In the version that you are using this approach is not available due to limited extensibility of this functionality. There is no other alternative to accomplish the desired scenario.
Greetings,Svett
the Telerik team
Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
0
Peter Bogoyavlensky
Top achievements
Rank 1
answered on 30 Jan 2014, 05:20 AM
How can I do it in version 2013.2.724.20 ?
I suppose that there is no *CreateFilteringDropDownMenu* method anymore.
I suppose that there is no *CreateFilteringDropDownMenu* method anymore.
0
Hello Peter,
Thank you for contacting Telerik Support.
In order to hide certain filter options in the Excel-like filtering pop up, using the specified version (2013.2.724) please have a look at the following code snippet:
However, I would recommend you a simpler approach using the FilterPopupInitialized event:
I hope this information helps. Should you have further questions, I would be glad to help.
Regards,
Desislava
Telerik
Thank you for contacting Telerik Support.
In order to hide certain filter options in the Excel-like filtering pop up, using the specified version (2013.2.724) please have a look at the following code snippet:
public
Form1()
{
InitializeComponent();
this
.radGridView1.CreateCell += radGridView1_CreateCell;
}
private
void
radGridView1_CreateCell(
object
sender, GridViewCreateCellEventArgs e)
{
if
(e.CellType ==
typeof
(GridHeaderCellElement))
{
e.CellType =
typeof
(CustomHeaderCellElement);
}
}
private
void
Form1_Load(
object
sender, EventArgs e)
{
this
.productsTableAdapter.Fill(
this
.northwindDataSet.Products);
this
.radGridView1.EnableFiltering =
true
;
this
.radGridView1.MasterTemplate.ShowHeaderCellButtons =
true
;
this
.radGridView1.MasterTemplate.ShowFilteringRow =
false
;
}
public
class
CustomHeaderCellElement : GridHeaderCellElement
{
public
CustomHeaderCellElement(GridViewColumn column, GridRowElement row) :
base
(column, row)
{
}
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(GridHeaderCellElement);
}
}
protected
override
IGridFilterPopup CreateFilterPopup()
{
RadListFilterPopup popup =
base
.CreateFilterPopup()
as
RadListFilterPopup;
((RadMenuItem)popup.Items[1]).Items[0].Visibility = ElementVisibility.Collapsed;
return
popup;
}
}
However, I would recommend you a simpler approach using the FilterPopupInitialized event:
private
void
radGridView1_FilterPopupInitialized(
object
sender, FilterPopupInitializedEventArgs e)
{
RadListFilterPopup popup = e.FilterPopup
as
RadListFilterPopup;
((RadMenuItem)popup.Items[1]).Items[0].Visibility = ElementVisibility.Collapsed;
}
I hope this information helps. Should you have further questions, I would be glad to help.
Regards,
Desislava
Telerik
TRY TELERIK'S NEWEST PRODUCT - APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>