LocalDataSourceProvider Observable Collection Refresh

2 posts, 1 answers
  1. Benedikt
    Benedikt avatar
    24 posts
    Member since:
    Feb 2018

    Posted 28 Oct 2019 Link to this post

    Hi guys,

     

    I have a PivotGrid with a LocalDataSourceProvider.

    The Itemsource of this LocalDataSourceProvider is a ObservableCollection.

    I set these Descriptions:

                Telerik.Pivot.Core.PropertyGroupDescription pgdKWJahr = new Telerik.Pivot.Core.PropertyGroupDescription();
                pgdKWJahr.PropertyName = "KWJahr";
                pgdKWJahr.SortOrder = SortOrder.None;
                Telerik.Pivot.Core.PropertyGroupDescription pgdBearbeiter = new Telerik.Pivot.Core.PropertyGroupDescription();
                pgdBearbeiter.PropertyName = "Bearbeiter";
                PropertyAggregateDescription padAnzahl = new PropertyAggregateDescription();
                padAnzahl.PropertyName = "Anzahl";

                using (ldspAnzahlÜbergabeWerk.DeferRefresh())
                {
                    ldspAnzahlÜbergabeWerk.RowGroupDescriptions.Add(pgdKWJahr);
                    ldspAnzahlÜbergabeWerk.ColumnGroupDescriptions.Add(pgdBearbeiter);
                    ldspAnzahlÜbergabeWerk.AggregateDescriptions.Add(padAnzahl);

                };

    If the ObservableCollection now changes, I have to call a Refresh on the LocalDataProvider:

    UcReklamationsAnzahlÜbergabeWerkVerlauf.ldspAnzahlÜbergabeWerk.Refresh();

     

    This is not that great, but works if a value changes.The problem is, it not triggers anything if a new item should appear or an item is removed.

    For better understanding:

    My Collection is a list of how much things a user in each week completed. If someone now changes the weekrange, there should appear the new weeks in this range.

     

    Is there any possibility to achieve this?

     

    Greetings

    Benedikt

  2. Answer
    Dinko
    Admin
    Dinko avatar
    982 posts

    Posted 31 Oct 2019 Link to this post

    Hello Benedikt,

    Thank you for the provided code snippet.

    The LocalDataSourceProvider.ItemsSource property does not notify for collection changed. In order to refresh the ItemsSource of the LocalDataSourceProvider whenever the ObservableCollection changes you should first set it to null and then to the new value. Setting the ItemsSource to null will cause clearing the engine and then when the new ItemsSource is set the engine can reinitialize with the correct data. Currently, there is no other available way to cause re-initialization and recalculation of the data.

    Regards,
    Dinko
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top