Disable one filter column

12 posts, 0 answers
  1. Andy
    Andy avatar
    107 posts
    Member since:
    Sep 2010

    Posted 04 Oct 2010 Link to this post

    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.
  2. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 06 Oct 2010 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andy
    Andy avatar
    107 posts
    Member since:
    Sep 2010

    Posted 07 Oct 2010 Link to this post

    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.
  5. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 07 Oct 2010 Link to this post

    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
  6. Andy
    Andy avatar
    107 posts
    Member since:
    Sep 2010

    Posted 07 Oct 2010 Link to this post

    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.
  7. Andy
    Andy avatar
    107 posts
    Member since:
    Sep 2010

    Posted 07 Oct 2010 Link to this post

    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.
  8. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 13 Oct 2010 Link to this post

    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
  9. Ammar
    Ammar avatar
    6 posts
    Member since:
    Sep 2011

    Posted 20 Oct 2011 Link to this post

    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;

            }

    }


  10. Achuthan
    Achuthan avatar
    31 posts
    Member since:
    May 2007

    Posted 15 Nov 2012 Link to this post

    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;

        }

    }
  11. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 16 Nov 2012 Link to this post

    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.
  12. Roger
    Roger avatar
    17 posts
    Member since:
    Aug 2012

    Posted 21 Jan 2013 Link to this post

    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
  13. Eyup
    Admin
    Eyup avatar
    3007 posts

    Posted 24 Jan 2013 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017