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
3914
Change ordinal of PivotDataColumn
posted

Hi,

How can I change a PivotDataColumn's ordinal in the list of PiotDataColumns?

For example, in the following picture, I want to programmatically move PivotDataColumn LME_NICKEL to the first position.

 

 

Thanks

Sangeetha

 

Parents
No Data
Reply
  • 8831
    Suggested Answer
    posted

    Hello,

    By design the members are created in the order of their appearance in items source and they are displayed in such order as well. So if you want to ensure that your members have given default order you have to order your items source in appropriate order.

    Also here is described how you can set the rules about how your members are ordered when header sorting is allowed.
    You need to create an hierarchy descriptor over the property used as a source property of this particular dimension.  Have a look at the code below:

    HierarchyDescriptor<ProductData> daysOfMonthDescriptor = new HierarchyDescriptor<ProductData>(pd => pd.Date);

    daysOfMonthDescriptor.HierarchyName = "Days Of Month";

    // uncomment in order to have a root level

    // daysOfMonthDescriptor.AddLevel(pd => "All Days Of Month", "All");

    daysOfMonthDescriptor.AddLevel(pd => pd.Date.DayOfMonth(), "Days Of Month");

     

    // provides the right items order based on their numeric values

    Expression<Func<ProductData, int>> orderByExpression = d => d.Date.DayOfMonthOrderKey();

    daysOfMonthDescriptor.LevelDescriptors[1].OrderByKeyExpression = orderByExpression;

     

    flatDataSource.HierarchyDescriptors.Add(daysOfMonthDescriptor);

     

     

    This code illustrates how Days of month hierarchy can be created. Because we want members to appear in right numeric (not string) order we set OrderByKeyExpression property to be an integer which refers to the position of each day.

    As order by key you can use the value returned by a property of your data class or you can make a call to an instance or extension method which have to return the value used to determine the column ordinal.

     

    Best regards.

    Plamen.

Children