Set Default Filter Values

4 posts, 0 answers
  1. Kevin
    Kevin avatar
    2 posts
    Member since:
    Mar 2014

    Posted 26 Mar 2014 Link to this post

    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. 
  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 31 Mar 2014 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Admins
    Admins avatar
    1 posts
    Member since:
    Apr 2013

    Posted 07 Aug 2014 Link to this post

    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
  5. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 12 Aug 2014 Link to this post

    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.

     
Back to Top