Please see FlatDataExample.xaml.cs in the attached project.
Note this section:
// Crashes here if hierarchies and levels have the same name. // However, changing names causes hierarchies not to display in pivot grid.
PeopleGrid.DataSource.Filters.Add(PeopleGrid.DataSource.CreateFilterViewModel( PeopleGrid.DataSource.Cube.Dimensions["Gender"].Hierarchies.First()));
PeopleGrid.DataSource.Filters.Add(PeopleGrid.DataSource.CreateFilterViewModel( PeopleGrid.DataSource.Cube.Dimensions["TypeCode"].Hierarchies.First())); I've tried changing the hierarchy and level names however when I do that the pivot grid does not display any dimenions.The code below is a WORKING page from a different project that is running the same version of Infragistics (I checked each dll).Why does it work?
<igFlatData:FlatDataSource x:Key="RollBookDataSource" x:Shared="False" Rows="[PIMCO_DESC].[Product],[BROKER].[Broker]" Columns="[Measure].[Measure]" Measures="Long,Short,Net"> <igFlatData:FlatDataSource.ConnectionSettings> <igFlatData:FlatDataConnectionSettings ItemsSource="{Binding}"/> </igFlatData:FlatDataSource.ConnectionSettings> <igFlatData:FlatDataSource.CubesSettings> <igFlatData:CubeMetadata DataTypeFullName="Poolman.Models.TBARollPivotItem"> <igFlatData:DimensionMetadata SourcePropertyName="Long" DisplayFormat="{}{0:#,#;(#,#)}"/> <igFlatData:DimensionMetadata SourcePropertyName="Short" DisplayFormat="{}{0:#,#;(#,#)}"/> <igFlatData:DimensionMetadata SourcePropertyName="Net" DisplayFormat="{}{0:#,#;(#,#)}"/> </igFlatData:CubeMetadata> </igFlatData:FlatDataSource.CubesSettings> <igFlatData:FlatDataSource.HierarchyDescriptors> <igFlatData:HierarchyDescriptor SourcePropertyName="{x:Static local:TBARollBook.kMeasure}"> <igFlatData:HierarchyDescriptor.LevelDescriptors> <igFlatData:HierarchyLevelDescriptor LevelName="Type" LevelExpressionPath="Measure.Type"/> </igFlatData:HierarchyDescriptor.LevelDescriptors> </igFlatData:HierarchyDescriptor> <igFlatData:HierarchyDescriptor SourcePropertyName="PM_NAME" HierarchyName="{x:Static local:TBARollBook.kFilterPM}"> <igFlatData:HierarchyDescriptor.LevelDescriptors> <igFlatData:HierarchyLevelDescriptor LevelName="All"/> <igFlatData:HierarchyLevelDescriptor LevelName="PM" LevelExpressionPath="PM_NAME"/> </igFlatData:HierarchyDescriptor.LevelDescriptors> </igFlatData:HierarchyDescriptor> <igFlatData:HierarchyDescriptor SourcePropertyName="DELIVERY_DT" HierarchyName="{x:Static local:TBARollBook.kFilterDelivery}"> <igFlatData:HierarchyDescriptor.LevelDescriptors> <igFlatData:HierarchyLevelDescriptor LevelName="All"/> <igFlatData:HierarchyLevelDescriptor LevelName="Delivery" LevelExpressionPath="DELIVERY_DT"/> </igFlatData:HierarchyDescriptor.LevelDescriptors> </igFlatData:HierarchyDescriptor> <igFlatData:HierarchyDescriptor SourcePropertyName="ROLL_IND" HierarchyName="{x:Static local:TBARollBook.kFilterRoll}"> <igFlatData:HierarchyDescriptor.LevelDescriptors> <igFlatData:HierarchyLevelDescriptor LevelName="Roll" LevelExpressionPath="ROLL_IND"/> </igFlatData:HierarchyDescriptor.LevelDescriptors> </igFlatData:HierarchyDescriptor> <igFlatData:HierarchyDescriptor SourcePropertyName="TURN_IND" HierarchyName="{x:Static local:TBARollBook.kFilterTurn}"> <igFlatData:HierarchyDescriptor.LevelDescriptors> <igFlatData:HierarchyLevelDescriptor LevelName="Turn" LevelExpressionPath="TURN_IND"/> </igFlatData:HierarchyDescriptor.LevelDescriptors> </igFlatData:HierarchyDescriptor> <igFlatData:HierarchyDescriptor SourcePropertyName="PIMCO_DESC" HierarchyName="{x:Static local:TBARollBook.kViewProduct}"> <igFlatData:HierarchyDescriptor.LevelDescriptors> <igFlatData:HierarchyLevelDescriptor LevelName="All"/> <igFlatData:HierarchyLevelDescriptor LevelName="Product" LevelExpressionPath="PIMCO_DESC"/> </igFlatData:HierarchyDescriptor.LevelDescriptors> </igFlatData:HierarchyDescriptor> <igFlatData:HierarchyDescriptor SourcePropertyName="BROKER" HierarchyName="{x:Static local:TBARollBook.kViewBroker}"> <igFlatData:HierarchyDescriptor.LevelDescriptors> <igFlatData:HierarchyLevelDescriptor LevelName="All"/> <igFlatData:HierarchyLevelDescriptor LevelName="Broker" LevelExpressionPath="BROKER"/> </igFlatData:HierarchyDescriptor.LevelDescriptors> </igFlatData:HierarchyDescriptor> </igFlatData:FlatDataSource.HierarchyDescriptors> </igFlatData:FlatDataSource> RollGrid.DataSource.Filters.Add(RollGrid.DataSource.CreateFilterViewModel( RollGrid.DataSource.Cube.Dimensions["PM_NAME"].Hierarchies.First())); FilterPM();
RollGrid.DataSource.Filters.Add(RollGrid.DataSource.CreateFilterViewModel( RollGrid.DataSource.Cube.Dimensions["DELIVERY_DT"].Hierarchies.First())); FilterDelivery();
RollGrid.DataSource.Filters.Add(RollGrid.DataSource.CreateFilterViewModel( RollGrid.DataSource.Cube.Dimensions["TURN_IND"].Hierarchies.First())); FilterTurn();
RollGrid.DataSource.Filters.Add(RollGrid.DataSource.CreateFilterViewModel( RollGrid.DataSource.Cube.Dimensions["ROLL_IND"].Hierarchies.First())); FilterRoll();
Yes, this code does crash. Wrap the code I highlighted earlier in a try block and put a breakpoint in it. You will see the exception below. Note that for some reason the exception is silent. It crashes on the first line shown below then execution returns to App.xaml.cs. However if you wrap it in a try block (or place a breakpoint on it ) you will catch the exception.
As I said there is a page in the project I'm working on that has working code (see my original post). For my page, I am unable to find the right combination of hierarchy/level names to use for the "Rows" and "Columns" properties of the flatdatasource. I only see dimenions on the pivotgrid if levelname and hierarchyname are the same. Of course, when the names are the same the filters cannot be added.
The version of the controls I am using is 11.2.20112.2125
try { PeopleGrid.DataSource.Filters.Add(PeopleGrid.DataSource.CreateFilterViewModel( PeopleGrid.DataSource.Cube.Dimensions["Gender"].Hierarchies.First()));
PeopleGrid.DataSource.Filters.Add(PeopleGrid.DataSource.CreateFilterViewModel( PeopleGrid.DataSource.Cube.Dimensions["TypeCode"].Hierarchies.First())); } catch (Exception ex) { // look at ex here }
Here is the exeception. If you look at PeopleGrid.DataSource.Filters.Count in the watch window you will see that it is zero. So I dont know why this exception is thrown.
Item is already added to the collection! at Infragistics.Olap.AreaItemsCollection.OnCollectionChanging(NotifyCollectionChangedEventArgs e) at Infragistics.Olap.SwapCollection`1.InsertItemInternal(Int32 index, T item, Boolean suppressMessages) at Infragistics.Olap.SwapCollection`1.InsertItem(Int32 index, T item) at System.Collections.ObjectModel.Collection`1.Add(T item) at PivotGridTest.FlatDataExample.PeopleGrid_Loaded(Object sender, RoutedEventArgs e) in \\Visual Studio 2010\Projects\PivotGridTest2\PivotGridTest\FlatDataExample.xaml.cs:line 123
Hi Sam,
Should I expect this sample to crash? If no, what I need to change in order to reproduce the crash?Using build 11.2.20112.2125 it works fine.
Plamen.