AllowFilteringByColumn property always false for RadGrid during life cycle prior to databinding

4 posts, 0 answers
  1. Bryan
    Bryan avatar
    8 posts
    Member since:
    May 2016

    Posted 01 Sep Link to this post

    Seems that in code behind the AllowFilteringByColumn property is always set to false at all phases of life cycle prior to the data binding stages. Code example like below for example is always returning me false.:

     

    protected void Page_Load(sender se, EventArgs evt) // Master Page event
    {
     
    var grid = ControlHelper.FindControlByCIDRecursive<RadGrid>(Request["__EVENTTARGET"], ContentPlaceHolder1); // Iterate content page to find all RadGrid
                    if (grid != null)
                    {
                        bool rebind = false;
                        if(grid.AllowFilteringByColumn)
                        foreach (GridColumn column in grid.MasterTableView.Columns)
                            if (column.CurrentFilterFunction!=GridKnownFunction.NoFilter) {
                            column.CurrentFilterFunction = GridKnownFunction.NoFilter;
                            column.CurrentFilterValue = string.Empty;
                                rebind = true;
                        }
                        if (rebind)
                        {
                            grid.MasterTableView.FilterExpression = string.Empty;
                            grid.MasterTableView.Rebind();
                        }
                    }
    }

     

    Our requirement is to apply a certain DOM class to all grids site-wise. If AllowFilteringByColumn is not propertly populated before databinding is there another way to determine whether filtering is enabled?

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 02 Sep Link to this post

    Hi Bryan,

    If you need to execute custom logic based on the AllowFilteringByColumn property you can use the Page_PreRender event. At that stage the property will indicate whether filtering is enabled for RadGrid.

    Regards,
    Viktor Tachev
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bryan
    Bryan avatar
    8 posts
    Member since:
    May 2016

    Posted 05 Sep Link to this post

    Thanks. Thought about this before but my downfall was the properties of the grid and its underlying masterview were different...

    If only that of the mastertableview is set to true then it would still return false during PreRender for the grid.

    Wonder if there's any specific reason/purpose for this behavior?

  5. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 07 Sep Link to this post

    Hello Bryan,

    The behavior you describe is expected. Note that the AllowFilteringByColumn is available for the RadGrid and for each GridTableView. This enables you to have hierarchical RadGrid where only some of the nested tables allow filtering. When you set the AllowFilteringByColumn property for the RadGrid this will be the default value for all GridTableViews that the grid contains.

    By default the filtering is disabled and this is why you are seeing false when checking the AllowFilteringByColumn for RadGrid.

    In case you are enabling filtering only for the MasterTableView you would need to check the AllowFilteringByColumn property for it.


    protected void Page_PreRender(object sender, EventArgs e)
    {
        if (RadGrid1.MasterTableView.AllowFilteringByColumn == true)
        {
            //do stuff
        }
    }


    Regards,
    Viktor Tachev
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top