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: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