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
1750
Hidden values in tuples
posted

Hi,

I have a pivotTable where I want to see in Rows a Geography dimension p.e. Countries.

For each country that I see in these rows I want to have hidden in my tuple the longtitude and latitude.

Can I do this and if yes how?

In general can I have hidden values in tuples ? For example could I fill somehow the Tag property ?  

Thank you,

Dimitris

Parents
  • 7922
    posted

    Hi,

    You can store extra metadata as attached properties set to DataRow. What i mean.

    1 Create Dummy class and register attached property for that class.

     public class ExtendProp : DependencyObject
        {
            #region PivotPartType
     
            /// <summary>
            /// Identifies the <see cref="PivotPartType"/> dependency property
            /// </summary>
            public static readonly DependencyProperty PivotPartTypeProperty =
                DependencyProperty.RegisterAttached(
                "PivotPartType",
                typeof(int),
                typeof(ExtendProp),
                new PropertyMetadata(0, OnPivotPartTypeChanged));
     
            /// <summary>
            /// Returns the value of PivotPartType attached property of a UIElement.
            /// </summary>
            /// <param name="obj">UIElement that this property is attached.</param>
            /// <returns>A value of the propery.</returns>
            public static int GetPivotPartType(DependencyObject obj)
            {
                return (int)obj.GetValue(PivotPartTypeProperty);
            }
     
            /// <summary>
            /// Sets the PivotPartType attached property to a UIElement.
            /// </summary>
            /// <param name="obj">The element to which the property is attached.</param>
            /// <param name="value">The value of the property.</param>
            public static void SetPivotPartType(DependencyObject obj, int value)
            {
                obj.SetValue(PivotPartTypeProperty, value);
            }
     
            private static void OnPivotPartTypeChanged(DependencyObject target, DependencyPropertyChangedEventArgs e)
            {
              
            }
     
            #endregion // PivotPartType
        }

    2. Attach value to row

    pivotGrid.LayoutLoaded += (s, e) =>
    {
        ExtendProp.SetPivotPartType(pivotGrid.DataRows[0], 9);
    };

     

    3 Read value

     int i = (int)ExtendProp.GetPivotPartType(pivotGrid.DataRows[0]);
    

    4 DataRow has Tuple property, so you can easy reach the tuple.

    this.pivotGrid.DataRows[0].Tuple
    

    In sample property is from int type, but it can be from any type in .NET

    Todor

Reply Children