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
I have copied your code into my project, and the cube ends up as null, and the rows, columns and measures all have count=0.
Any ideas what I could be doing wrong?
Hello,
When I use the RIA I create the instance of DomainDataSource into resources of the layout root
<Grid.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}">
Then I set the bindings as follow
<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>
Also you can check the event handler of LoadedData event for errors or exceptions.
Regards.Plamen.
Plamen,
Can you give more details on "DomainDataSource.Data property as ItemsSource of FlatDataSource" I'm trying to bind xamPivotGrid with RIS Services. But not getting any data. So trying to genrate FlatdataSource out of my DomaindataSource.
<riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:vwTranDetail, CreateList=true}" Height="0" LoadedData="vwTranDetailDomainDataSource_LoadedData" Name="vwTranDetailDomainDataSource" QueryName="GetVwTranDetailsQuery" Width="0">
<my:CSFContext /></riaControls:DomainDataSource.DomainContext>
<ig:XamPivotGrid x:Name="pivotGrid" Grid.Column="0" DataSource="{Binding Source=vwTranDetailDomainDataSource, Path=Data}" />
Thanks for your help
Sandip
Hello Tonny,
Do you use RIA services or you have your own service to process the database? If you are using RIA services then you can set DomainDataSource.Data property as ItemsSource of FlatDataSource. FlatDataSource is sensitive about DispalyAttribute.AutoGenerateField, DispalyAttribute.Name and DispalyFormatAttribute.DataFormatString metadata.
Plamen.
YOu know what, finally the above code worked. Am now trying to to use the xampivotgrid on a database but clueless on how to do that. Will be greatful for any help provided. thanks