When I Hide/Collapse the FILTER button in the column header, it doesn't remove the space from the header until the user clicks in the row/header. I must be doing something wrong. Currently, I am using the ViewCellFormatting event to hide/collapse the FilterButton.
Any ideas?
Thanks.
2 Answers, 1 is accepted
Hello Mark,
I am assuming that Excel-like filtering is enabled. If you want to disable the filter option of a specific column, you can set the AllowFiltering property of the column to false. You can get the required column from the Columns collection. Keep in mind that the Columns collection will be populated after the DataSource property is set.
this.radGridView1.EnableFiltering = true;
this.radGridView1.MasterTemplate.ShowHeaderCellButtons = true;
this.radGridView1.MasterTemplate.ShowFilteringRow = false;
this.radGridView1.DataSource = items;
this.radGridView1.Columns[1].AllowFiltering = false;
Here is the result:
Can you give this approach a try and let me know if it works for you?
Regards,
Dinko | Tech Support Engineer
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Okay, you gave me something to look at and I think I found the problem, but I am having a hard time repoing it in an example, but in my application, moving the HeaderTextAlignment = ContentAlignment.MiddleRight before you set AllowFiltering = false on the column fixed my problem.
Thanks for at least pointing me in the right direction to figure this out.
I will keep trying to make my sample project do what my application is doing and then I will submit it.
So, after more research, I added the following event to my abstract class of my RadGridView
private void myRadGridView_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
if (e.CellElement is GridHeaderCellElement { ColumnInfo: GridViewDataColumn gvColumn } ghCellElement)
{
if (!gvColumn.AllowFiltering)
{
ghCellElement.FilterButton.Visibility = ElementVisibility.Collapsed;
}
else
{
ghCellElement.FilterButton.Visibility = ElementVisibility.Visible;
}
}
}
Thank you for sharing your approach. If I have correctly understood, you have found a solution for your case. Let me know if I am wrong.
If you have any other questions, feel free to open new thread and we will be happy to help.