New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

Access and determine applied filters

Description

RadPivotGrid provides built-in Includes/Excludes filtering. After the user filters the PivotGrid content, you may want to be able to get this information for indication or other reasons.

Solution

You can use the following approach to achieve this requirement:

C#
bool isFiltered = false;
protected void RadPivotGrid1_ItemCommand(object sender, PivotGridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.FilterCommandName)
    {
        isFiltered = true;
    }
}
protected void RadPivotGrid1_PreRender(object sender, EventArgs e)
{
    if (isFiltered)
    {
        PivotGridFiltersCollection filters = RadPivotGrid1.Filters;
        StringBuilder sb = new StringBuilder("<br/><b>Currently applied filters:</b><br/>");
        foreach (PivotGridLabelGroupFilter filter in filters.OfType<PivotGridLabelGroupFilter>())
        {
            string colName = filter.FieldName;
            PivotGridSetCondition condition = filter.Condition as PivotGridSetCondition;
            sb.Append(colName + ": " + condition.Comparison + " - "
                + string.Join(", ", condition.Items.Select(x => x.ToString())) + "<br/>");
        }
        Label1.Text = sb.ToString();
    }
}
In this article
DescriptionSolution
Not finding the help you need?
Contact Support