Load on Demand

2 posts, 0 answers
  1. Raul
    Raul avatar
    20 posts
    Member since:
    Apr 2014

    Posted 28 Dec 2015 Link to this post

    Hello,

     I'm currently testing the RadGridView with Load On Demand behaviour and I'm having some issues.

     

    I'm using Entity Framework and when grouping the GridView the rows within some groups appear twice. This happens sometime just after opening the groups but sometimes not until clicking on the row within the group. Then a second row appears within that group.

    This only happens when using VirtualQueryableCollectionView as ItemsSource of the GridView. When using ObservableCollection everything is ok. It's also in both cases ok, when no grouping is used - also when removing the grouping after having the duplicated rows. The affected groups are mostly those displayed at the top of the gridview. When changing the sort order of the column before grouping the column, the groups with duplicated rows are at the bottom.

     

    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Linq;
    using Telerik.Windows.Controls;
    using Telerik.Windows.Data;
    using GalaSoft.MvvmLight.Messaging;
     
    namespace PsShell.ViewModels.Articles.CtlArticleMainSelection {
        public class ArticleMainSelectionViewModel : ViewModelBase {
     
            public delegate ArticleMainSelectionViewModel Factory();
     
            public ArticleMainSelectionViewModel() {
            }
       
             private PsShell.Models.Articles.CtlArticleMainSelection.ArticleModel _selectedArticle = null;
            public PsShell.Models.Articles.CtlArticleMainSelection.ArticleModel SelectedArticle {
                get {
                    return _selectedArticle;
                }
                set {
                    _selectedArticle = value;
                    OnPropertyChanged("SelectedArticle");
                }
            }
     
    //        private ObservableCollection<Models.Articles.CtlArticleMainSelection.ArticleModel> _articles = null;
    //        public ObservableCollection<Models.Articles.CtlArticleMainSelection.ArticleModel> Articles {
            private VirtualQueryableCollectionView _articles = null;
            public VirtualQueryableCollectionView Articles {
                get {
                    if (_articles == null) {
                        var context = new Models.Articles.CtlArticleMainSelection.ArticleContext();
                        var query = from gp in context.BusinessPartner
                                    orderby gp.geschaeftspartner_id ascending
                                    select new Models.Articles.CtlArticleMainSelection.ArticleModel() {
                                        Name1 = gp.Name1,
                                        Name2 = gp.Name2
                                    };
     
                        _articles = new VirtualQueryableCollectionView(query) { LoadSize = 50, VirtualItemCount = 150 };    // duplicate row in group
    //                    _articles = new ObservableCollection<Models.Articles.CtlArticleMainSelection.ArticleModel>(query); // ok
                    }
                    return _articles;
                }
            }
        }
    }
     

     

    <UserControl x:Class="PsShell.Views.Articles.CtlArticleMainSelectionView"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:globalization="clr-namespace:System.Globalization;assembly=mscorlib"            
                 xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                 mc:Ignorable="d"
                 d:DesignHeight="800" d:DesignWidth="1400">
     
          <DockPanel LastChildFill="True">
            <telerik:RadGridView x:Name="gvArticles" ItemsSource="{Binding Articles}" SelectedItem="{Binding SelectedArticle, Mode=TwoWay}"
                                 IsReadOnly="True" EnableRowVirtualization="True" EnableColumnVirtualization="True"
                                 AutoGenerateColumns="False" ShowGroupPanel="True" GroupRenderMode="Flat"
                                 IsSynchronizedWithCurrentItem="True" SelectionMode="Single"
                                 FilteringMode="FilterRow" ScrollMode="RealTime">
     
                <telerik:RadGridView.SortDescriptors>
                    <telerik:ColumnSortDescriptor Column="{Binding Columns[\Name1\], ElementName=gvArticles}" SortDirection="Ascending"/>
                </telerik:RadGridView.SortDescriptors>
     
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name1}" Width="400" ShowDistinctFilters="False"/>
                    <telerik:GridViewDataColumn Header="Namenszusatz / Vorname" DataMemberBinding="{Binding Name2}" Width="300" ShowDistinctFilters="False"/>
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
        </DockPanel>
     </UserControl>

     

    A second issue is the performance. When using ObservableCollection as ItemsSource the performance is ok. But when using VirtualQueryableCollectionView the performance is unacceptable slow. I can see the empty grid for about 2 seconds before it is populated with data - and this with a Loadsize of 50 items (in this example it's a bit faster because I reduced the columns from about 10 to 2). I noticed that when using GroupRenderMode="Nested" the performance is noticeable faster, but that isn't the recommended way because of performance issues when using nested grouping.

     

    Best Regards

    Raul

  2. Martin Vatev
    Admin
    Martin Vatev avatar
    90 posts

    Posted 30 Dec 2015 Link to this post

    Hello,

    Data Virtualization of group items is not fully supported and that is the reason why RadGridView behaves strangely when you try to group it. The idea of the data virtualization is to load only a necessary data but RadGridView grouping scenario should have all. Here you can find some more info about the data virtualization's limitations.

    I hope that this helps. Should you have any other questions, do not hesitate to contact us.

    Regards,
    Martin Vatev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top