Hi,
We're using Infragistics WPF v12.2 (sorry can't upgrade right now).
I'm making a measure editable by adding it in to the EditableMeasures collection when the measure it's added to the PivotGrid's measures collection.
private void MeasuresOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{ switch (e.Action) { case NotifyCollectionChangedAction.Add: foreach (IMeasureViewModel mvm in e.NewItems) { if (mvm.Caption == "Locus" || mvm.Caption == "Cleanup") { PivotGrid.EditSettings.EditableMeasures.Add(mvm.Measure); PivotGrid.DataSource.SetMeasureAggregator(mvm,AggregationHelper.GetDefaultAverageAggregator(typeof(double))); } } break; case NotifyCollectionChangedAction.Remove: foreach (IMeasureViewModel mvm in e.OldItems) { PivotGrid.EditSettings.EditableMeasures.Remove(mvm.Measure); } break; } }
What am I missing?
Thanks.
Please refer to the attached sample. I have used your code and it works on my side. You can check also the XAML file but I think yours should be the same.
Thanks,
M.Yovchev
Do you think the problem is related to how my flatDataSource and grid are set up? Please see below the XAML for both:
<igOlap:FlatDataSource x:Key="FlatDataSource" Rows="[Currency].[Currency], [AdjustmentType].[AdjustmentType]" Measures="USDAmount, LocalAmount,Pnl,NetLocalAmount,RemainLocal,RemainUSD,Locus,Cleanup" Cube="Restricted NDF" > <igOlap:FlatDataSource.CubesSettings> <igOlap:CubeMetadata DataTypeFullName="Item"> <igOlap:DimensionMetadata SourcePropertyName="USDAmount" DisplayName="USD Amount" /> <igOlap:DimensionMetadata SourcePropertyName="LocalAmount" DisplayName="Local Amount" /> <igOlap:DimensionMetadata SourcePropertyName="Pnl" DisplayName="PnL To Trade" DimensionType="Measure"/> <igOlap:DimensionMetadata SourcePropertyName="NetLocalAmount" DisplayName="OCS" DimensionType="Measure"/> <igOlap:DimensionMetadata SourcePropertyName="RemainLocal" DisplayName="Remaining" DimensionType="Measure"/> <igOlap:DimensionMetadata SourcePropertyName="RemainUSD" DisplayName="Remaining (USD)" DimensionType="Measure"/> <igOlap:DimensionMetadata SourcePropertyName="Locus" DisplayName="Locus" DimensionType="Measure" /> <igOlap:DimensionMetadata SourcePropertyName="Cleanup" DisplayName="Cleanup" DimensionType="Measure"/> </igOlap:CubeMetadata> </igOlap:FlatDataSource.CubesSettings> <igOlap:FlatDataSource.HierarchyDescriptors> <igOlap:HierarchyDescriptor SourcePropertyName="Currency" HierarchyName="Currency"> <igOlap:HierarchyDescriptor.LevelDescriptors> <igOlap:HierarchyLevelDescriptor LevelName="Currency" LevelExpressionPath="Currency" /> </igOlap:HierarchyDescriptor.LevelDescriptors> </igOlap:HierarchyDescriptor> <igOlap:HierarchyDescriptor SourcePropertyName="AdjustmentType" HierarchyName="AdjustmentType"> <igOlap:HierarchyDescriptor.LevelDescriptors> <igOlap:HierarchyLevelDescriptor LevelName="AdjustmentType" LevelDisplayName="Type" LevelExpressionPath="AdjustmentType" /> </igOlap:HierarchyDescriptor.LevelDescriptors> </igOlap:HierarchyDescriptor> </igOlap:FlatDataSource.HierarchyDescriptors> </igOlap:FlatDataSource>
<ig:XamPivotGrid x:Name="PivotGrid" AllowCompactLayout="True" DataSource="{StaticResource FlatDataSource}" > <ig:XamPivotGrid.DataCellTemplates> <ig:DataCellTemplate Template="{StaticResource NumericCellTemplate}" ColumnLabel="PnL To Trade"/> <ig:DataCellTemplate Template="{StaticResource NumericCellTemplate}" ColumnLabel="USD Amount"/> <ig:DataCellTemplate Template="{StaticResource NumericCellTemplate}" ColumnLabel="Local Amount"/> <ig:DataCellTemplate Template="{StaticResource NumericCellTemplate}" ColumnLabel="Remaining"/> <ig:DataCellTemplate Template="{StaticResource NumericCellTemplate}" ColumnLabel="OCS"/> <ig:DataCellTemplate Template="{StaticResource NumericCellTemplate}" ColumnLabel="Locus"/> <ig:DataCellTemplate Template="{StaticResource NumericCellTemplate}" ColumnLabel="Cleanup"/> <ig:DataCellTemplate Template="{StaticResource NumericCellTemplate}" ColumnLabel="Remaining (USD)"/> </ig:XamPivotGrid.DataCellTemplates> <ig:XamPivotGrid.ColumnHeaderTemplates> <ig:HeaderTemplate Template="{StaticResource TestDataTemplate}" Label="USD Amount"/> </ig:XamPivotGrid.ColumnHeaderTemplates> <ig:XamPivotGrid.EditSettings> <ig:EditSettings AllowCellEdit="True" /> </ig:XamPivotGrid.EditSettings>
Another difference is that my FlatDataSource's ItemSource is an object of type ICollectionView.
This how it get initialised:
var cvs = CollectionViewSource.GetDefaultView(_items); cvs.Filter = o => { var item = o as Item; return item != null && item.ShowRow; }; DataContext = controller_; PivotGrid.SelectionSettings.CellSelection = PivotSelectionType.Multiple; PivotGrid.DataSource.Measures.CollectionChanged += MeasuresOnCollectionChanged;
_flatDataSource = (FlatDataSource)Resources["FlatDataSource"]; _flatDataSource.ConnectionSettings = new FlatDataConnectionSettings { ItemsSource = cvs };
Regards.