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
515
Changing DataSource on XamPivotGrid and Expander on Code
posted

I have a XamPivotGrid and Expander which use a defined XmlaDataSource when the application loads. I would like to change the Rows, Columns, Measures, etc .. in code when the users selects a item from a dropdown. Do you have a simple example of this?

Parents
No Data
Reply
  • 7922
    Suggested Answer
    posted

    Hi

     

    In case where you don’t want to use XamDataSelector for pupolate xamPivotGrid with data, you should work with data source metadata tree.

     

    Bellow is example how you can add dimension for the rows in xamPivotGrid

     

    XmlaDataSource ds = pivotGrid.DataSource as XmlaDataSource;

    HierarchicalItem root = ds.Metadata[0];

    HierarchicalItem dimension = root.Items[3];

     

    IHierarchy herarchy = null;

    if (dimension.ItemType == ItemTypes.Dimension)

    {

        herarchy = ((Dimension)dimension.DataObject).Hierarchies[0];

    }

               

    IFilterViewModel fvm = pivotGrid.DataSource.CreateFilterViewModel(herarchy);

    pivotGrid.DataSource.Rows.Add(fvm);

     

    Notice the you should browse your own metadata and select the dimension you want to add to the pivotGrid based on user choice from your dropdowns

     

    Regards

    Todor

     

     

Children
No Data