Hello,
I'am having a critical bug when I do FlatDataSource.LoadCustomizations which crash all the application. I have added a sample project to reproduce this bug: When launched, try to add a group by field of "book", and then try to filter on books "754K" and "754L", And ou will see on the group by fields "AssetType" and "Book" and with data only on books "754K" and "754L". And then you click Refresh, then the "Item is already added" exception is throwed and application crashes. What happens is that when you click Refresh, it will change the ItemSource by an List of data that doesn't have book 754L, and I think FlatDataSource.LoadCustomizations doesn't like this.
You just have to launch the sample project and add the field Book and filter, and then click, you will see the bug. Can you please urgently give me a solution to this problem? Because this exception is not catchable and is fatal. Thanks a lot
Regards
Hi pebg,
This exception occurs because LoadCustomization is trying to add saved rows/columns/filters that are already present inside the FlatDataSource. Your FlatDataSource has set the InitialValue for the Measures, Rows and Columns properties and this causes those dimensions/measures to be reloaded automatically if you change the ItemsSource. What you should instead do is manually add the Measures, Columns and Rows that you want to be present when the FlatDataSource is created. The following post is a good example showing how to manually add these:http://ko.infragistics.com/community/forums/p/65089/329572.aspx#329572
This approach requires that the FlatDataSource has been assigned to the pivot grid before you can access the FlatDataSource.Cube property so you will probably need to change your code a bit to make this work. But it needs to be done if you want to call LoadCustomizations and not have the exception occur due to the FlatDataSource trying to apply the initial values on top of what is being loaded from the customizations.
What we want is that when setting the ItemSource to the FlatDataSource, we keep all the filters and Columns of the Grid. I hoped doing so by LoadCustomizations, but apparently this cause some problems.
This works. I can now refresh the content of my PivotGrid and keeps the filters that I have. Thank a lot!
I updated your sample to add the Measure, Column and Row as per the method described in that forum thread I linked earlier. I believe this was the only change I made. It is inside your BucketRiskFlatDataSourceFactory.cs file.
Actually the application crashes even without setting the filters: We just have to launch it and then click on the Refresh. Otherwise, it works if we don't do SaveCustomization/LoadCustomizations. It's really weird.