I was to use the xamPivotDataSelector off my own metadata to drive a query that will then return a result set which I can then bind to the datasource of the grid. Unfortunately it seems I can only bind to my own objects using FlatDataSource. This requires a result set, e.g. the response from a pre run query.
Is there any way for me to populate a xamPivotDataSelector manually on the fly? E.g. I am going to query a business tier which will supply dimensions, measures etc. I want to put them in the selector so a user can drop them into rows and columns/measures, then I grab those, query the backend and get back a dataset I can bind to another grid/selector for further slicing and dicing.
Is this possible? I want to use it like you can in excel, which points to a datasource, which shows the fields you can use, u pick them all then it goes and queries (I will intercept events and build/run queries on the fly)
E.g.
xamPivotDataSelector.Measures.Add(myListOfMeasures)
//same for dimensions
Hi,
You can populate xamPivotDataSelector only by its DataSource property. DataSource property can be FlatDataSource (it works with custom data) or XmlaDataSource (it works with Analysis server data). If want to work with your own business tier, you should use FlatDataSource.
To manipulate data in selector you should create your own object which should contains the data from which the selector will generate dimensions and measures. If you know the data in advance this is not problem, but if you don’t know your data you should dynamically generate classes for dimensions and measures.
Please describe me in more details what you try to accomplish, so I will be able to give you more detail info.
Regards
Todor
I have a list of dimensions, the associated fields, and the measures that I want to build my meta model off of. I want to have the selector show up with those dimensions/measures available to select. Then once the user selects them and clicks a "Go" button i put on there, I want it to query the backend using the selected dimensions/measures (I will write this code) and return a result which I will bind to another pivotgrid in the traditional manner.
Can I do something like this to build a selector from scratch?
IMeasureViewModel mvm = myFlatDataSource.CreateMeasureViewModel(new Measure("MyCalc", "MyCalc", "MyCalc", "MyCalc", "Measures", Hopefully a custom aggregator here));
myFlatDataSource.Measures.Add(mvm);
Hello,
If I understand you correct you want to use FlatDataSource with your own data selector. Maybe you know that when you set the ItemsSource and FlatDataSource.Cube then a dimension is created for each public property exposed by type of the items in the items source, and a measure is created as well when the property type is kind of number. I have sample solution attached where you can find how I have used two ListBoxs to select dimensions and measures and add the selection to pivot grid. It also demonstrates how you can use your own aggregation context. At this moment that’s possible only from code behind.
If you have any additional questions please write me back.
Best regards.
Plamen.
This is great but I have a few questions regarding it:
1. Is there anyway to drive the Itemsource from a dictionary or another object that contains the dimensions and measures I want to expose. (I won't have an object that represents the result set e.g. your ProductData object, just a list of dimension and measures). Otherwise I will have to use IL or reflection to emit a class that represents the result row which I want to avoid. In the wpf controls you could bind grid columns based on keys in a dictionary...
2. What exactly is the AggregationContext? It seems to apply to every dimension record, what if I just want it to apply to subtotaling and not incur overriding the calc for every row?
3. How does it AggregationContext differ from datasourceProvider.MeasureAggregations?
4. In the aggregation context, is there a way to get a reference to the current record that is passing in the "addValue"? I want to look at other properties on it aside from the value for that measure to determine the value I want to use. (e.g. based on productName I want return a different value, I don't care what the measure is)
5. Is there any documentation covering any of the stuff we are discussing here?