13 Answers, 1 is accepted
I'm not sure that I understand your question completely. You can set AllowFIltering property to false if you want to disable the filtering for that column.
<telerik:GridBoundColumn AllowFiltering="false" DataField="...
Kind regards,
Daniel
the Telerik team

That's what I need. But I would like to do the code in VB.
I tried using "radGrid1.MasterTableView.Columns(1)" but I can't find the attribute of
AllowFiltering
Andy.
I recommend that you access the column by its unique name rather that by its index. You should then cast it to the corresponding type in order to access the desired property.
TryCast(RadGrid1.MasterTableView.GetColumn(
"MyColumn"
), GridBoundColumn).AllowFiltering =
False
<telerik:GridBoundColumn UniqueName="MyColumn" ...
Best regards,
Daniel
the Telerik team

But it doesn't work. No error happens and also no effect on the Filter. I'm using the GridTemplateColumn. So here is my code
TryCast(radGrid1.MasterTableView.GetColumn(
"MyColumn"
), GridTemplateColumn).AllowFiltering =
False
Andy.

But when I place in the Page_Load. It works. No idea about that.
But I need it in the ItemCreated.
Thanks!
Andy.
You cannot achieve that on ItemCreated. Instead, you can hide the filter cell of the desired column, provided that you insist to use this event.
Protected
Sub
RadGrid1_ItemCreated(sender
As
Object
, e
As
GridItemEventArgs)
If
TypeOf
e.Item
Is
GridFilteringItem
Then
TryCast(e.Item, GridFilteringItem)(
"MY_COLUMN_NAME"
).Text =
" "
End
If
End
Sub
The idea is that setting text in the cell will clear the Controls collection.
Best regards,
Daniel
the Telerik team

protected void RadGrid1_ItemCreated(Object sender , GridItemEventArgs e )
{
if (e.Item.GetType()== typeof(GridFilteringItem))
{
((GridFilteringItem)e.Item)["YourColumnName"].Enabled = false;
}
}

I want to Hide the filter for one particular column . i wrote the code like given below but it doesnt work
Please guyide me to do that.
protected void RadGrid1_ItemCreated(object sender , GridItemEventArgs e )
{
if (e.Item.GetType() == typeof(GridFilteringItem))
{
((GridFilteringItem)e.Item)["Performance Graph"].Enabled = false;
}
}

Try the following code to achieve your scenario.
C#:
protected
void
RadGrid1_PreRender(
object
sender, EventArgs e)
{
RadGrid1.MasterTableView.GetColumn(
"Uniquename"
).ShowFilterIcon =
false
;
RadGrid1.Rebind();
}
Thanks,
Shinu.

None of these solutions worked for me either!
My grid has dynamically added columns (this.RadGrid.DataSource = dataTable, set within OnNeedDataSource event) and for a subset of these columns filtering should be disabled (really meaning no filter textbox etc. shown).
Besides the non-working solutions I tried some workarounds like setting FilterControlWidth (Column.FilterControlWidth = Unit.Pixel(0)), finding controls within corresponding cell and hiding them (cell.Controls[0].Visible = false, in ItemCreated event etc.). Another workaround would have been to get ClientID values of filter controls and hiding them by JavaScript. But I didn't find an easy way to get those IDs on server-side.
Did anybody find a working solution for this simple functionality?
Thanks and best regards,
Roger
Can you please verify whether you have closely followed the steps provided in this topic?
http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html#Section4
If so, then the following approach should work as expected:
boundColumn.AllowFiltering =
false
;
That should do the trick. Please give it a try and let me know if it works for you.
Greetings,
Eyup
the Telerik team

allow filtering = false dosent get rid of the filtering dropdown. can I get rid of the filtering for just one or two columns and leave it on the other 6 columns? thanks.
Hi Rick,
The AllowFiltering="false" should work and you can see how to use it in this demo: https://demos.telerik.com/aspnet-ajax/grid/examples/functionality/filtering/filter-templates/defaultcs.aspx.
In the first grid, the AllowFiltering option is set to false inside the first column and the filter dropdown is not shown:
<telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" Width="100%" DataSourceID="SqlDataSource1" AllowFilteringByColumn="True"
AllowSorting="True" AllowPaging="True" PageSize="7" runat="server" AutoGenerateColumns="False"
OnPreRender="RadGrid1_PreRender" ShowStatusBar="true" EnableLinqExpressions="false">
<MasterTableView DataKeyNames="CustomerID" TableLayout="Fixed">
<Columns>
<telerik:GridBoundColumn UniqueName="ContactName" DataField="ContactName" HeaderText="Contact name"
AllowFiltering="false" HeaderStyle-Width="200px" />
...
Regards,
Rumen
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.