Radgrid column filters

2 posts, 0 answers
  1. Tim
    Tim avatar
    8 posts
    Member since:
    May 2015

    Posted 08 Jun 2015 Link to this post

    I'm using RadGrid for an application.

    The rendered grid has filters on top of each column.  When I supply a value and select any filter from the dropdown (e.g. contains, Begins with, etc) the form posts back to the server.

    I'm trying to determine the event handler for this postback.

    Please advise.

     Thank you,

    Tim Inouye

  2. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 11 Jun 2015 Link to this post

    Hi Tim,

    You can access the filter value using the following approach:
    Copy Code
    Copy Code
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.FilterCommandName)
        {
            string colName = (e.CommandArgument as Pair).Second.ToString();
            if (colName == "ShipCountry")
            {
                string value = e.Item.OwnerTableView.GetColumn(colName).CurrentFilterValue;
            }
        }
    }

    Or using a similar implementation as the following:
    Copy Code
    Copy Code
    Copy Code
    protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns)
        {
            string filterValue = col.CurrentFilterValue;
            GridKnownFunction filterFunction = col.CurrentFilterFunction;
     
            if (!string.IsNullOrEmpty(filterValue))
            {
                string result = col.UniqueName + ": " + filterValue;
            }
        }
    }

    This way you can access the filter value defined by the user and use it to execute any custom logic.


    Hope this helps.


    Regards,
    Eyup
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top