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
630
Hierarchies and dynamic objects
posted

Hello,

Please excuse if I'm missing some basic concepts here. I'm attempting to something along the lines of this code snippet, which I found on another forum post:

HierarchyDescriptor<ProductData> dateTimeTodayDescriptor = new HierarchyDescriptor<ProductData>(pd => pd.Today);

dateTimeTodayDescriptor.AddLevel(pd => "Today", "All Dates");

dateTimeTodayDescriptor.AddLevel(pd => pd.Today.SemesterWithYear(), "Semesters");

dateTimeTodayDescriptor.AddLevel(pd => pd.Today.MonthShort(), "Months");

 

However, instead of a known class (in the example, "ProductData"), the ItemSource for my XamPivotGrid consists of a list of dynamic objects created using Infragistics.Olap.DynamicTypeBuilder. I have the property names of the object available in string variables. Any suggestions on how I might modify this example to handle my situation?

I've also tried a completely different approach such as:

// Create a HierarchyDescriptor for a property whose name is stored in col.ColumnName (I'd like it displayed using the string in col.Caption)...

var hier = new HierarchyDescriptor
{
    SourcePropertyName = col.ColumnName,
    HierarchyName = col.Caption,
    HierarchyDisplayName = col.Caption,
};

// Then add a hierarchy level for the property...

HierarchyLevelDescriptor yLevel = new HierarchyLevelDescriptor                    

 {                     

    LevelName = "Years",                     

    LevelExpressionPath = col.ColumnName                     

};                    

System.Linq.Expressions.Expression<Func<DateTime, int>> eY = date => date.Year;                     

yLevel.LevelExpression = eY;                    

hier.LevelDescriptors.Add(yLevel);


But this doesn't work at all (note that the "System.Linq.Expressions....." line is a total guess, since the LevelExpression property has no useful documentation whatsoever -- please take note that "gets or sets the LevelExpressions property"  as the entire explanation doesn't tell us much).

Hopefully I've communicated what I'm trying to do here. Any suggestions of a way to get it done would be greatly appreciated!


And as a side note, what does the HierarchyDisplayName property actually do? It seems to have no effect -- the top of each Hierarchy shows in the XamPivotDataSelector as the ugly raw property name, not the nicer looking "caption" I'm trying to set it to. Can't find a way around that one either...


Thanks,

Bob

Parents Reply Children
No Data