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

Set Default Filter Values

3 Answers 219 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 27 Mar 2014, 04:30 AM
Is it possible to set default values for filters within PivotGrid?

For example, within my PivotGrid I have a Column Field 'Year', and I want this to be automatically filtered by the past 2 years on load. 

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 31 Mar 2014, 02:21 PM
Hi Kevin,

In order to set filters in RadPivotGrid that are applied initially you could use the PreRender event and define the values that would be used in the filter. You could specify the filter with the
FilterByLabel() method. If you would like you could check out the example of using the method in this article.


Regards,
Viktor Tachev
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
0
Admins
Top achievements
Rank 1
answered on 07 Aug 2014, 02:58 PM
Hi,

Thank you for this link but I am not succeed to apply a filter on the year when this field is defined as PivotGridReportFilterField

If I want to select the current year, how can I do that?

Regards
A
0
Viktor Tachev
Telerik team
answered on 12 Aug 2014, 10:26 AM
Hello,

You could try the FilterByLabel and FilterByValue methods of the RadPivotGrid.

FilterBylabel:

protected override void OnPreRender(EventArgs e)
{
    base.OnPreRender(e);
    RadPivotGrid1.FilterByLabel(PivotGridFilterFunction.Contains, RadPivotGrid1.Fields["Cost"], "filter value");
}

protected override void OnPreRender(EventArgs e)
{
    base.OnPreRender(e);
    RadPivotGrid1.FilterByLabel(PivotGridFilterFunction.IsNotBetween, RadPivotGrid1.Fields["Cost"], "filter value", "beetween filter value");
}

FilterByValue:

protected override void OnPreRender(EventArgs e)
{
    base.OnPreRender(e);
    RadPivotGrid1.FilterByValue(PivotGridFilterFunction.BeginsWith,
        RadPivotGrid1.Fields["Line"],
        RadPivotGrid1.Fields["Total"] as PivotGridAggregateField,
        "filter value");
}

protected override void OnPreRender(EventArgs e)
{
    base.OnPreRender(e);
    RadPivotGrid1.FilterByValue(PivotGridFilterFunction.IsBetween,
        RadPivotGrid1.Fields["Line"],
        RadPivotGrid1.Fields["Total"] as PivotGridAggregateField,
        "filter value",
        "between filter value");
}


Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
PivotGrid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Admins
Top achievements
Rank 1
Share this question
or