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://es.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.
Thank you very much for your reply. Actually the exception occurs when we try to Set the ItemsSource of the FlatDataSource to another collection of contents by these lines:
var layout = this.SaveCustomizations(); ItemsSource = dataItems; this.LoadCustomizations(layout);
By if we do this without doing Saving/Loading the customizations like this:
ItemsSource = dataItems;
It worked. So I believe it's because the reason that you talked about: Since we have done SaveCustomizations and we try to reload the dimensions/Measures when wo set the ItemsSource.
I have tried the solution mentioned in the other thread, but it seems no working. Can you please fix the issue based on the sample project that I have provided in the attachement? That would save me a lot of energy and time trying and guessing. Thanks a lot!