Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
605
FlatDataSource exception/bug?
posted

Hello,

I am starting this new thread as my recent posts  to original thread

(   http://forums.infragistics.com/forums/t/64100.aspx ) are sitting unanswered for few weeks already.

I hope this  new thread will draw some attention of IG support to the FlatDataSource problems that I am not able to resolve since autumn of 2011.

I believe PivotGrid   FlatDataSource is not bullet-proofed  design to handle frequent data source updates, especially its total reset/refresh. I am experiencing either plain exception from FlatDataSource (“System.InvalidOperationException was unhandled. Message=Collection was modified; enumeration operation may not execute.”)  or my Pivot Grid is not being “refreshed” e.g. not displaying updated data source.

Here is the link to uploaded test solutions  illustrating the problems. :

http://www.sendspace.com/filegroup/ZigUnhkp80nV%2FXVM%2FvTB2g

Inside you’ll find 2 zipped solutions.

1.      FlatDataSourceException_Observable.zip (17.75MB) – solution using regular ObservableCollection as data source.

2.      FlatDataSourceException_ControlledNotifications.zip – solution with derived (from ObservanleCollection) collection as data source..

1.    Exception on frequent update (adding items to collection) is happening in solution

 When data source is loaded (added in the loop few dozens of data items )

Sequence of steps to repro :

-          Run solution #1 .

-          - Watch output window – RefreshPositions() method in STSPositionViewModel.cs file executes AddPosition(pos) – line 225 in the loop. After few incretions (5 or 6 items) , FlatDataSource throws exception :   System.InvalidOperationException was unhandled. Message=Collection was modified; enumeration operation may not execute.

-           at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)

-             at System.Collections.Generic.List`1.Enumerator.MoveNextRare()

-             at System.Collections.Generic.List`1.Enumerator.MoveNext()

-             at Infragistics.Olap.FlatData.FlatDataModelProvider.OnAddItemsToItemsSource(ItemsSourceChangedEventArgs eventArgs, IList`1& relevantDataObjects, IList`1& modifiedHierarchies)

-             at Infragistics.Olap.FlatData.FlatDataModelProvider.OnUpdateHierarchiesData(ItemsSourceChangedEventArgs args)

-             at Infragistics.Olap.FlatData.FlatDataModelProvider.<>c__DisplayClass17.<ItemsSourceChanged>b__15()

-             at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

-             at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)

-             at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

-             at System.Threading.ThreadHelper.ThreadStart()”

2.    Refresh/Update

To fight FlatDataSourceException described just above I am using in solution #2 a  collection derived from ObservableCollection. It allows to suspend OnCollectionChanged events before loading the data and resume them after the data is loaded.

In my solution FlatDataSource  behaves  more or less normally ONLY when my underlying Data Source ( orig.source ) is created first and only then instance of PivotDataGrid is created and  its FlatDataSource is assigned an instance of orig.source.

If the sequence is reversed - and this is a typical scenario when we save pivot grid  layout into config and first create it (grid) and assign to its data source an instance of empty  orig.source,  Pivot Grid is not displaying the data inserted  later from data access layer into orig.source.

Even if I call on timer a forceful  PivotGrid.DataSource.RefreshGrid()  it does not help.

Sequence of steps to repro Refersh/Update related problems:

-          Run solution #2.

-          Watch output window and main app. window . You’ll see that first grid with empty data source is created from config. Then data source by default is populated with 35 items

-          PivotGrid is not displaying them. Call to PivotGrid.DataSource.RefreshGrid()   does not help. Inside of this method though (line 979 in PivotGridViewModel.cs) there is DebugWrite statement writing the PivotGrid FlatDataSource ItemSource count to Output window. So, you’ll see that data is present and being refreshed , but Pivot Grid does not reflect these changes .

Like I’ve mentioned before I am using 11.2 IG release and I have style xaml file from IG 11.2 Feature Browser samples for Pivot Grid, namely IG.xamPivotGrid.xaml.  May be there some problems with styles/resources as quite often I see the following error “System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:(no path); DataItem=null; target element is 'DragSource' (HashCode=38770302); target property is 'DataObject' (type 'Object')”  

I was not able to identify the source of this error in my custom code.

Lastly there is another issue I want to mention. In our real solution we deal with rather large amount of data to be displayed in xamDataGrid and dissected in PivotGrids.  Even if I use as data source a custom collection with controllable suspend/resume notification on CollectionChanged evens I still sometimes run into NoValid Operation exception described in upper sections of this doc. Here is my take at the reasons why, illustrated by pseudo code :

Application.Current.Dispatcher.BeginInvoke(new Action(() =>

          {

              try

              {

                

scanRows.SuspendCollectionChangeNotification();

                  scanRows.Clear();

 

 

                  foreach (AresAccessGroup group in _tab.Groups)

                          scanRows.Add(mv);

                                 

              }

              catch (Exception ex)

              {

                  …..

              }

              finally

              {

                  scanRows.ResumeCollectionChangeNotification();

              }

          }));

 

ALWAYS WORKS OK FIRST TIME.

Then (I guess) next time, which can come any moment,  FlatDataSource whose  IiemSource is assigned to the instance of _scanRows, is not finished yet its processing of Hierarchy rebuilding and/or something else and call to either    scanRows.Clear(); or    scanRows.Add(mv);  even despite suspended notification bombs out FlatDataSource.

 

Questions

1.       I am trying to get an answer on this forum for few times already for this question – if FlatDataSource is able to handle underlying data source updates refreshes in safely fashion ?

2.       If yes, what exposed methods/properties of it I should use to avoid the exceptions/abnormal behaviour described above ?

3.       Can you please help with update/refresh of pivot grid ?

 

Thanks a lot in advance,

Alex

 

 

 

 

 

 

 

 

Parents
No Data
Reply
  • 138253
    Offline posted

    Hello Alex,

     

    I updated the other forum thread, since there is more information and the other users may benefit from the answers as well.

Children
No Data