Hiding the Filter at Page Load

4 posts, 0 answers
  1. Michael O'Flaherty
    Michael O'Flaherty avatar
    67 posts
    Member since:
    Jun 2010

    Posted 06 Mar 2013 Link to this post

    Hi!

    This may be obvious but I am missing it. I created a button in the CommandItemTemplate to toggle the filter. It is in javascript and works fine. However, I would prefer to display the grid with the filter hidden from the start. Is there a property in the aspx definition or in the code behind that can set that?

    Using CSS seems to hide it permantly:
    .radGrid .rgFilterRow
    {
        display: none !important;
    }

    Thanks for your help!
    Michael
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Mar 2013 Link to this post

    Hi,

    Try the following code.
    C#:
    void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
            if (e.Item is GridFilteringItem)
            {
                GridFilteringItem item = (GridFilteringItem)e.Item;
                item.Visible = false;
            }
    }

    Thanks,
    Shinu
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Michael O'Flaherty
    Michael O'Flaherty avatar
    67 posts
    Member since:
    Jun 2010

    Posted 07 Mar 2013 Link to this post

    Thanks for the reply! Unfortunately, this seems to have the same effect as the CSS -- it hides the filter on every postback. We would like to be able to toggle the setting. Do we have to manage this ourselves? Is there some way to initially hide it in the radGrid_Init event?
  5. Michael O'Flaherty
    Michael O'Flaherty avatar
    67 posts
    Member since:
    Jun 2010

    Posted 07 Mar 2013 Link to this post

    This seems to work for me. Thanks again for your help!

    protected void radGridReferrals_Init(object sender, EventArgs e)
    {
         RadGrid radGrid = (RadGrid)sender;
         radGrid.MasterTableView.IsFilterItemExpanded = false;
    }
Back to Top