Get Filter Values

Posted by: vinukovdenis on 3 August 2017, 4:01 pm EST

  • Posted 3 August 2017, 4:01 pm EST

    Hello



    There is any way to receive the established values of filters from PivotView.



    For example the user established the filter for date, how to receive values which were used by the user in the filter



    Thank You!
  • Replied 3 August 2017, 4:01 pm EST

    vda,

    You can use the following code to get the list of filters that are applied to the Pivot View.

    var Filters=_pivotview.GetLayoutState().Filters

    This code will return you a collection of filter items that are applied to the Pivot View. I have also attached a sample application to demonstrate the same as well.


    Best Regards,
    Abhishek
    2012/07/LayoutActions.zip
  • Replied 3 August 2017, 4:01 pm EST

    Thanks for the answer



    In your sample you have set filter by la.SetFilter("[Measures].[Total Product Cost]", 1000, 2000);



    then you have Expression, FilterType, Value (like at pict1.png)



    I have connection to Database with MDX, and after connect load pivot state with filter by date



    using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(streamLoadState))

    {

    this.PivotView.Read(reader, GrapeCity.ActiveAnalysis.Silverlight.PersistSettings.Layout);

    }

    ... from .analysis file

    -->



    PivotView load and set filter to 05.07.2012,06.07.2012,07.07.2012,08.07.2012 but then i use

    var Filters=_pivotview.GetLayoutState().Filters

    I don't see Expression, FilterType, Value like in your sample (pict2.png)



    I don't see what date the user chose for the filter.
    2012/07/Pictures.zip
  • Replied 3 August 2017, 4:01 pm EST

    vda,

    It seems that the filter returned is of the type IMemberFilter . You can use the following code to get the selected value for of this filter type.

    private void button1_Click(object sender, EventArgs e)
            {

        
                foreach (IFieldFilter filter in _pivotView.GetLayoutState().Filters)

                {

                    if (filter.ToString().Contains("MemberFilter"))
                    {

                        IMemberFilter member = (IMemberFilter)filter;


                        IEnumerable Schemamember = member.RootMembers;

                        foreach (var k in Schemamember)
                        {

                            MessageBox.Show("Filter Name"+filter.ToString()+Environment.NewLine+"Caption:"+k.Caption +Environment.NewLine +"Is Included:"+member.IsMemberIncluded(k));
                        
                        }

                    }

               }


    I have also attached a sample application which demonstrates how you can get selected values for all filter types i.e IHeadingFilter, IMemberFilter,IRangeFilter, ITopNFilter and IValueFilter. Please go through the same and let me know if this helps.


    Best Regards,
    Abhishek


    2012/07/LayoutActions-2.zip
  • Replied 3 August 2017, 4:01 pm EST

    Thank You :)

    Now it works fine!
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels