Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
130
Duplicated measures in XamPivotDataSelector
posted

Is it possible to remove measures from "columns/rows" section in data selector?

I would like to set them visible in section "1" (under "measures" tree node) but I would like to remove them from section "2":

  • 27093
    Verified Answer
    posted

    Hello,

     

    I have been investigating this and have found a way for you to achieve your goal by iterating through the DataSource’s HierarchicalItems. Here is a code snippet you can use in the property changed event of the DataSource of your XamPivotDataSelector:

     

    dataSelector.DataSource.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(DataSource_PropertyChanged);

     

    void DataSource_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)

    {

        if (e.PropertyName == "Metadata")

        {

            HierarchicalItem rootItem = (sender as DataSourceBase).Metadata[0];

            List<HierarchicalItem> theChosenOnes = new List<HierarchicalItem>();

     

            foreach (HierarchicalItem item in rootItem.Items)

            {

                if ((item.Caption=="Units sold")||(item.Caption=="Amount of sale"))

                {

                    theChosenOnes.Add(item);

                }

            }

            if (theChosenOnes.Count>0)

            {

                foreach (var item in theChosenOnes)

                {

                    rootItem.Items.Remove(item);

                }

            }

        }

    }

     

    Please let me know if you require any further assistance on the matter.

     

     

    Sincerely,

    Petar Monov

    Developer Support Engineer

    Infragistics Bulgaria

    www.infragistics.com/support