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

Disable one filter column

13 Answers 807 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Andy asked on 04 Oct 2010, 09:53 PM
Hi all!
I would like to make one filter column of RadGrid disable in order not to allow user touch on it.
Could anyone help me?

Thanks!

Andy.

13 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 06 Oct 2010, 09:44 PM
Hello Andy,

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
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
Andy
Top achievements
Rank 1
answered on 07 Oct 2010, 05:49 PM
Thanks for relying, Daniel!

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.
0
Daniel
Telerik team
answered on 07 Oct 2010, 09:27 PM
Hello 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
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
Andy
Top achievements
Rank 1
answered on 07 Oct 2010, 11:27 PM
Thanks Daniel!
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.
0
Andy
Top achievements
Rank 1
answered on 07 Oct 2010, 11:45 PM
The code doesn't work in "radGrid1_ItemCreated"
But when I place in the Page_Load. It works. No idea about that.
But I need it in the ItemCreated.

Thanks!

Andy.
0
Daniel
Telerik team
answered on 13 Oct 2010, 04:03 PM
Hello 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 = "&nbsp;"
    End If
End Sub

The idea is that setting text in the cell will clear the Controls collection.

Best regards,
Daniel
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
Ammar
Top achievements
Rank 1
answered on 20 Oct 2011, 03:43 PM
In case you need C# code for that here it is:

 

 

protected void RadGrid1_ItemCreated(Object sender , GridItemEventArgs e )

 

{

  if (e.Item.GetType()== typeof(GridFilteringItem))

 

        {

            ((GridFilteringItem)e.Item)["YourColumnName"].Enabled = false;

        }

}


0
Achuthan
Top achievements
Rank 1
answered on 15 Nov 2012, 12:19 PM
Hi,

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;

    }

}
0
Shinu
Top achievements
Rank 1
answered on 16 Nov 2012, 08:10 AM
Hi,

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.
0
Roger
Top achievements
Rank 1
Veteran
answered on 21 Jan 2013, 03:34 PM
Hi all

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
0
Eyup
Telerik team
answered on 24 Jan 2013, 06:52 AM
Hello 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
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Rick
Top achievements
Rank 1
answered on 15 Apr 2021, 07:06 PM

 

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.
0
Rumen
Telerik team
answered on 20 Apr 2021, 01:56 PM

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/.

Tags
Filter
Asked by
Andy
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Andy
Top achievements
Rank 1
Ammar
Top achievements
Rank 1
Achuthan
Top achievements
Rank 1
Shinu
Top achievements
Rank 1
Roger
Top achievements
Rank 1
Veteran
Eyup
Telerik team
Rick
Top achievements
Rank 1
Rumen
Telerik team
Share this question
or