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
425
How to set Columns, Rows, Measures
posted

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].&amp;[United Kingdom]}"
                                Measures="Reseller Sales Amount"
                                Rows="[Geography].[City]"
                                >
  • 8831
    Suggested Answer
    posted

    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.