is there any sample code for binding an arbitrary collection of objects to the pivot grid. For example, I dont want to go through RIA to connect to the server, I just want to report on a collection of data I have. The following code does not work:
public
class Data
{
public DateTime Date { get; set; }
public string Ticker {get;set;}
public double Value { get; set; }
}
List
<Data> data = new List<Data>();
data.Add(
new Data{
Date =
DateTime.Parse("1/1/2000"),
Ticker =
"IBM",
Value = 1.0
});
this.xamPivotGrid1.DataSource = data;
It wants an instance of IOlapViewModel
Thanks in advance
how to bring "Measures" into Row Fields area?
FYI: I got rid of the dataexpander control, and added
<
igOlap:FlatDataSource x:Key="flatDataSource" ... to the resouces section of the xaml, and now it displays the correct info (the Rows collection still says it has count of 0 but I see data - weird!)
I am not using RIA services - I am generating the list in code as in the example.
Hello,
Now I've seen that there is missing part in my code and it is mislead. I’m going to edit the previous post.Actually you need this:
In resources:
<riaControls:DomainDataSource x:Key="ddsProducts"
AutoLoad="True"
LoadedData="productDomainDataSource_LoadedData"
Name="productDomainDataSource" QueryName="GetProducts">
<riaControls:DomainDataSource.DomainContext>
<web:ProductsDomainContext/>
</riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
<FlatData:FlatDataConnectionSettings x:Key="flatDataSettings"
ItemsSource="{Binding Source={StaticResource ddsProducts}, Path=Data}"/>
<FlatData:FlatDataSource x:Key="flatDataSource"
Cube="ProductData"
ConnectionSettings="{StaticResource flatDataSettings}">
In LayouRoot:
<PivotGrid:XamPivotGrid x:Name="pivotGrid"
DataSource="{StaticResource flatDataSource}">
</PivotGrid:XamPivotGrid>
<PivotGrid:Expander Header="RIA data" Grid.Column="1" IsExpanded="True">
<PivotGrid:XamPivotDataSelector Grid.Column="1" x:Name="dataSelector"
DataSource="{StaticResource flatDataSource}"/>
</PivotGrid:Expander>
Best regards.PPilev.
Oops - the reply has appeared at the bottom (it's my first time!), so I should add that I am trying to use the folowing code as suggested above:List<Data> data = new List<Data>();
new Data{Date = DateTime.Parse("1/1/2000"),Ticker = "IBM",Value =1.0});
FlatDataSource
flatDataSource = new FlatDataSource
ItemsSource = data,
Cube =
DataSourceBase.GenerateInitialCube("Data"),
Rows =
DataSourceBase.GenerateInitialItems("[Date]"),
Columns =
DataSourceBase.GenerateInitialItems("[Ticker]"),
Measures =
DataSourceBase.GenerateInitialItems("Value")
};
and as stated above, flatDataSource.Cube is null, and flatDataSource.Rows = 0.
Hope that makes my question clearer!