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
Hi
To provide data to XamPivotGrid you should create DataSource that XamPivotGrid can read. Such oblects are FlatDataSource and XmlaDataSource. The first type is used when you have IEnumerable and want to show this data in the grid. The second type is used when you have analysis server as MS SQL Analysis server 2008. In your case you should FlatDataSource. Below is the code you can use to provide your data:
List<Data> data = new List<Data>();
data.Add(new Data
Date = DateTime.Parse("1/1/2000"),
Ticker = "IBM",
FlatDataSource flatDataSource = new FlatDataSource
ItemsSource = data,
Cube = DataSourceBase.GenerateInitialCube("Data"),
Rows = DataSourceBase.GenerateInitialItems("[Date]"),
Columns = DataSourceBase.GenerateInitialItems("[Ticker]"),
Measures = DataSourceBase.GenerateInitialItems("Value")
};
pivotGrid.DataSource = flatDataSource;
The cube is your class that contains properties with data – here is “Data”. For rows and columns you should provide properties whose data will be shown in rows or in column and for measure you provide property with data for cells. Finally you have to assign XamPivotGrid’s DataSource samples. In addition you can use HierarchyDescriptor<Data> to customize the look of the data in rows, columns and cell. You can see more complex sample about HierarchyDescriptor here http://labs.infragistics.com/silverlightdv/2010.2/#/Samples/PivotGrid/Basic/DataSourceFlatDataCB
Regards
Todor
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?
Hi, thanks for the post. Am a beginner with Netadvantage infragistics. I have been trying to get myself acquainted with the xampivotgrid control. I have used the above code in a project and I have put code for assigning the datasource to the pivotgrid in a click event of a button. however, when i run the project nothin happens. is there something am missing?
basically what am trying to do is have a simple datasource from which i can display the data in the contol, say even a mysql database. i have gone through the documentation on the help site but it doesnot give much detail. any help will be greatly appreciated. thanks in advance
Pane
; }
And in Code Behind
pane = new Pane();
List<string> geography = new List<string>();
List<string> product = new List<string>();
List<string> unit = new List<string>();
List<string> valuePane = new List<string>();
geography.Add(
"Household");
"Grocery Outlets");
product.Add(
"Rinse Conditioners");
"Main Wash");
"Deodorants");
"Tumble Drying Enhancer");
"Iron Enhancer");
"Special Wash");
"Wash Treatment");
unit.Add(
"Unit Sales");
"Value Sales");
"Volume Sales");
valuePane.Add(
pane.Geography = geography;
pane.Product = product;
pane.Units = unit;
pane.Value = valuePane;
List<Pane> pn = new List<Pane>();
pn.Add(pane);
FlatDataSource flatDataSource = new FlatDataSource()
ItemsSource = pn,
Cube =
DataSourceBase.GenerateInitialCube("Geography"),
Rows =
DataSourceBase.GenerateInitialItems("Test"),
Measures =
DataSourceBase.GenerateInitialItems("Value)
pivotgrid.DataSource = flatDataSource;
pivotSelector.DataSource = flatDataSource;
But its displaying the Result as System.Collections.Generic.List. Its not displaying the actual data from the List.
Columns =
DataSourceBase.GenerateInitialItems("Product"),
Thanks, much appreciated. I have one further question. What package is the FlatDataSource in? Im using the trial version of the software v10.2, and I cant find this class. I found some documentation somewhere that indicated it was in Infragistics.Olap.FlatData, but I dont see this pakcage. Do I need to download another library, or what am i missing?
Thanks
-brent