I need to know how I can define rows, columns, filters and measures like you in the xaml below through code.
I need to bind to each property and due to the fact that those are not DependencyObjects I need to listen to the propertychanged of my viewmodel and set those manually. Unfortunatly I cannot find out how to add rows, measures, filters etc. to the datasource through code.
Please let me know. This is very urgent.
<olap:XmlaDataSource x:Key="DataSource" Columns="[Date].[Calendar]" Cube="Adventure Works" Database="Adventure Works DW Standard Edition" Filters="[Sales Territory].[Sales Territory Country]{[Sales Territory].[Sales Territory Country].&[United Kingdom]}" Measures="Reseller Sales Amount" Rows="[Geography].[City]" >
Hello,
You can add columns/rows/filters/measures using this code:
pivotGrid.DataSource.DeferredLayoutUpdate = true;
IMeasure measure = pivotGrid.DataSource.Cube.Measures["Reseller Sales Amount"];
IMeasureViewModel measureViewModel = pivotGrid.DataSource.CreateMeasureViewModel(measure);
pivotGrid.DataSource.Measures.Add(measureViewModel);
IDimension dateDimension = pivotGrid.DataSource.Cube.Dimensions["[Date]"];
IHierarchy dateCalendarHierarchy = dateDimension.Hierarchies["[Date].[Calendar]"];
IFilterViewModel columnViewModel = pivotGrid.DataSource.CreateFilterViewModel(dateCalendarHierarchy);
pivotGrid.DataSource.Columns.Add(columnViewModel);
// updates grid layout
pivotGrid.DataSource.DeferredLayoutUpdate = false;
Regards.Plamen.
Great but how could that work for rows as well?
I really appreciate your answer! Thanks so much
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
If the above suggestion helped you solve your issue please verify the thread as answered so other users may take better advantage of it.
Hi
For rows you should use datasource's rows collection like snippet below:
pivotGrid.DataSource.Rows.Add(rowViewModel);
Todor