Hi,
I spent all day trying to find the answer and failed, so here's the question. I have a flat datasource that I'd like to show in xamPivotGrid. I tried a number of ways but for simplicity here it is.
public class Data { public DateTime Date { get; set; } public string Ticker { get; set; } public string Ticker2 { get; set; } public double Value { get; set; } }
public override void OnDataLoaded() {
List<Data> data = new List<Data>(); data.Add(new Data { Date = DateTime.Parse("1/1/2000"), Ticker = "IBM", Ticker2 = "MSFT", Value = 1.0 }); data.Add(new Data { Date = DateTime.Parse("1/1/2000"), Ticker = "AEE", Ticker2 = "YSI", Value = 2.0 }); FlatDataSource flatDataSource = new FlatDataSource { ItemsSource = data, Cube = DataSourceBase.GenerateInitialCube("Data"), Rows = DataSourceBase.GenerateInitialItems("[Date]"), Columns = DataSourceBase.GenerateInitialItems("[Ticker],[Ticker2]"), Measures = DataSourceBase.GenerateInitialItems("Value") }; flatDataSource.RefreshGrid(); PivotDataSource = flatDataSource; NotifyPropertyChanged("PivotDataSource");}
The code above resides in the ViewModel. DataSource property of the grid and the selector is bound to PivotDataSource property of the ViewModel.
The code works and I get the values in the grid but I can't figure out how not to use the selector to select the rows and columns but do it programatically (preferably once and for all). Any advice?
Thank you,
Gene
Hi
The format for initial loaded dimensions is as folow; [DimensionName].[HierarchyName]. In case when you have one hierarchy, like yours, The dimension name and hierarchy name are the same.
Based on this your code should be like below
you can read more about in follow link
RegardsTodor
One more question - how do I show Totals column and row. The data shows up great now but I cant get the totals to show up.
Eugene
Figured it out.