Hi,
I am getting this error while I am using LoadCustomizations. My question is why it is taking duplicate sorters ? Also how to remove the duplicate filters ?
<DataSourceSnapshot> <DataSourceType>Flat</DataSourceType> <Rows> <FilterViewModel> <HierarchyUniqueName>[Book].[Book]</HierarchyUniqueName> </FilterViewModel> </Rows> <Measures> <string>Current Holding</string> <string>Proceeds</string> </Measures> <MeasureListIndex>0</MeasureListIndex> <MeasureListLocation>Columns</MeasureListLocation> <DefferedUpdate>false</DefferedUpdate> <SortDescriptors> <ArrayOfString> <string>DESC</string> <string>Current Holding</string> </ArrayOfString> <ArrayOfString> <string>DESC</string> <string>Open Holding</string> </ArrayOfString> <ArrayOfString> <string>DESC</string> <string>Current Holding</string> </ArrayOfString> <ArrayOfString> <string>DESC</string> <string>Current Holding</string> </ArrayOfString> </SortDescriptors></DataSourceSnapshot>
System.ArgumentException: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value) at Infragistics.Olap.DataSourceBase.MapSortDescriptors() at Infragistics.Olap.DataSourceBase.SortResult() at Infragistics.Olap.DataSourceBase.RunWorkerCompleted(Object sender, DoWorkCompletedEventArgs e) at Infragistics.Olap.DataSourceBase.BackgroundWorker.OnDoWorkCompleted(DoWorkCompletedEventArgs e) at Infragistics.Olap.DataSourceBase.BackgroundWorker.AsyncOperationCompleted(Object arg) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
Hi Rajib,
Thank you for the update. Let me know whether this helps.
Thanks for that. I will test and let you know.
Hi and thank you for posting!
I have been looking into the described behavior and it seems that it could due to the timing conflict between the GenerateInitialItems and LoadCustomizations methods. In order to correct this behavior you can either selectively use GenerateInitialItems when creating the new GroupingFlatDataSource only if the user has not already saved customizations that will be loaded, or you can make sure that the LoadCustomizations in the Loaded event waits for all pending work and is executed after that by using a Dispatcher as follows: void PivotGrouping_Loaded(object sender, RoutedEventArgs e){ // When we attempt to load customizatoins on grid load, we get an exception (Item already added) Dispatcher.BeginInvoke(new Action(() => { LoadCustomizations(); }), System.Windows.Threading.DispatcherPriority.Background, null);} Please feel free to let me know if you have any questions or if this approach does not help you.