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

Radgrid column filters

1 Answer 166 Views
Documentation and Tutorials
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 08 Jun 2015, 04:40 PM

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

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 11 Jun 2015, 10:08 AM
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
Tags
Documentation and Tutorials
Asked by
Tim
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or