Hey folks,
First of all, would just like to say I have been extremely impressed with these forums and the help I've received here -- it has really helped to illuminate the full flexibility of the product. Thanks everybody!
Okay, here is my next question, which is a bit broad in scope: What we really need to be able to do with Pivot Grid is have it dynamically configured based on an XML file (of our own design) so that our support team can quickly configure a cube for each customer without touching C# code. Specifically, we need to be able to configure Pivot Grid in three different "dimensions" that need to be dynamically loaded, which is to say, changeable via some kind of configuration file rather than a re-compile of C# code. Right now, the only Pivot Grid examples I've seen show the cube dimensions and calculations bound to the methods, properties and structure of a statically compiled C# object model. This is very cool, but the problem is that it is fixed at compile-time.
I need to be able have the cube load based on an XML file that dynamically specifies dimensions to load, expressions that lay behind certain calculated fields, and expressions that lay behind certain aggregators.
Right now, the only approach I can think of (which I'm willing to do if all else fails), is to use reflection to dynamically construct my data-binding classes at runtime (based on this config file I'm talking about), then incorporate some lightweight expression evaluator (http://flee.codeplex.com/) to parse and evaluate expressions embedded in the config file, which will represent either calculated dimensions, or custom aggregators.
Thoughts? Is this the only possible approach or is there something simpler that is already part of the framework?
-Jesse
Hello,For this purpose you can use the non-generic version:
HierarchyDescriptor regionRepDescriptor =
new HierarchyDescriptor { SourcePropertyName = "Region" };
// this will add a single root element
regionRepDescriptor.AddLevel("All Values", "All Values");
HierarchyLevelDescriptor regionLevel =
new HierarchyLevelDescriptor { LevelExpressionPath = "Region", LevelName = "Regions" };
HierarchyLevelDescriptor cityLevel =
new HierarchyLevelDescriptor { LevelExpressionPath = "City", LevelName = "Cities" };
regionRepDescriptor.LevelDescriptors.Add(regionLevel);
regionRepDescriptor.LevelDescriptors.Add(cityLevel);
flatDataSource.HierarchyDescriptors.Add(regionRepDescriptor);
Here LevelExpressionPath points to your dynamic property name.
Regards.
Plamen.
Okay, I think this is starting to make sense... I now have a pivot grid with dynamically inferred properties based on an XML file. Now what I'm not sure how to do is use many of the other features in the API, which seem to depend on statically bound type checking, generics, etc...
For example, I would like to be able to define a hierachy so that I can collapse my dynamically created dimensions and see summations. However, the code I've found for hierarchies seems to want to directly refer to properties on statically typed classes, for example, the example below depends on having compile-time access to the properties of the "ProductSale" type... But my type is dynamically generated, so the compiler doesn't know what properties to expect! Is there some way to re-write the below and pass in strings that name the properties, in place of direct, compile-time references to the properties?
Thanks!-Jesse
HierarchyDescriptor<ProductSale> sellerHierarchy = new HierarchyDescriptor<ProductSale>(p => p.Product);sellerHierarchy.HierarchyName = "Products";sellerHierarchy.AddLevel(p => "All product", "All product");sellerHierarchy.AddLevel(p => p.Product, "Product");_flatSource.AddHierarchyDescriptor(sellerHierarchy);
Hi
You can read this post about how to create dinamicaly your datasource. You can not escape from binding to properties because it is a concept of all silverlight and wpf.
RegardsTodor