This is a migrated thread and some comments may be shown as answers.

GridView with custom virtualization

4 Answers 753 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Subarna Bandyopadhya
Top achievements
Rank 1
Subarna Bandyopadhya asked on 17 Jun 2011, 11:44 PM
Hi,
We have a custom data virtualization component that we use as the itemsource for the radgridview. The data virtualization component is build on the sample project at the following location
http://www.codeproject.com/KB/WPF/WpfDataVirtualization.aspx

In my project,I have downloaded the source from the above site and  I have 2 windows , one that contains a wpf toolkit grid (ToolkitDataGrid.xaml) and the other that contains the telerik grid (TelerikDataGrid.xaml). The wpf grid works well with the virtualization component and only fetches rows that are in the visible area of the grid.
 
The telerik grid on the other hand fetches all the rows instead of only the visible ones.
This is a very critical requirement and I would be very grateful for any help/assistance.

With Windows datagrid 
<Window x:Class="DataVirtualization.ToolkitDataGrid"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dg="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit" 
        Title="ToolkitDataGrid" Height="600" Width=" 700" >
    <Grid>
          
        <Button Height="50" Width=" 100" Content="Load" Click="Button_Click"  VerticalAlignment="Top"/>
            <dg:DataGrid Name="dataGrid" Margin="5,100,5,5" 
                         ItemsSource="{Binding}"
                         AutoGenerateColumns="False"
                     ScrollViewer.IsDeferredScrollingEnabled="True"
                     VirtualizingStackPanel.VirtualizationMode="Recycling"
                     VirtualizingStackPanel.IsVirtualizing="True"  >
                <dg:DataGrid.Columns>
  
                    <dg:DataGridTextColumn Binding="{Binding Id}" Header="Id" />
                    <dg:DataGridTextColumn Binding="{Binding Name}" Header="Name" />
                </dg:DataGrid.Columns>
            </dg:DataGrid>
          
    </Grid>
</Window>

C# code behind
using System.Windows;
namespace DataVirtualization
{
    /// <summary>
    /// Interaction logic for ToolkitDataGrid.xaml
    /// </summary>
    public partial class ToolkitDataGrid : Window
    {
        public ToolkitDataGrid()
        {
            InitializeComponent();
        }
  
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DemoCustomerProvider customerProvider = new DemoCustomerProvider(1000000, 1000);
            var results=new VirtualizingCollection<Customer>(customerProvider, 20);
            DataContext = results;
        }
    }
}

The same thing with the telerik grid:
<Window
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView" xmlns:GridView="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" x:Class="DataVirtualization.TelerikDataGrid"
        Title="TelerikDataGrid" Height="600" Width=" 700" >
    <Grid>
        <Button Height="50" Width=" 100" Content="Load" Click="Button_Click"  VerticalAlignment="Top"/>
        <Controls:RadGridView x:Name="dataGrid" Margin="5,100,5,5" 
                         ItemsSource="{Binding}"
                         AutoGenerateColumns="False"
                     ScrollViewer.IsDeferredScrollingEnabled="True"
                     VirtualizingStackPanel.VirtualizationMode="Recycling"
                     VirtualizingStackPanel.IsVirtualizing="True" DataLoadMode="Asynchronous">
            <Controls:RadGridView.Columns>
  
                <Controls:GridViewDataColumn DataMemberBinding="{Binding Id}" Header="Id" />
                <Controls:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="Name" />
            </Controls:RadGridView.Columns>
        </Controls:RadGridView>
    </Grid>
</Window>

c# code behind
using System.Windows;
  
namespace DataVirtualization
{
    /// <summary>
    /// Interaction logic for TelerikDataGrid.xaml
    /// </summary>
    public partial class TelerikDataGrid : Window
    {
        public TelerikDataGrid()
        {
            InitializeComponent();
        }
  
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DemoCustomerProvider customerProvider = new DemoCustomerProvider(1000000, 1000);
            var results = new VirtualizingCollection<Customer>(customerProvider, 20);
            DataContext = results;
        }
    }
}

4 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 20 Jun 2011, 07:51 AM
Hello Subarna Bandyopadhya,

Have you considered using our own data virtualization mechanism? It is guaranteed to work with our controls and also it is an official product of Telerik. 

All the best,
Milan
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Subarna Bandyopadhya
Top achievements
Rank 1
answered on 20 Jun 2011, 08:31 AM
Hi,
Thanks for your reply. The custom data virtualization control  we are using cannot be changed as it is being used by other  controls in the system. However, we are flexible about using the "VirtualQueryableCollectionView" approach if it can accept our custom vistualized list as a parameter like this:

 VirtualizingCollection<Customer> results = new VirtualizingCollection<Customer>(customerProvider, 20);
  VirtualQueryableCollectionView vqResults = new VirtualQueryableCollectionView(results) { LoadSize = 20, VirtualItemCount = 1000000 };
DataContext = vqResults;

However, with this approach , I noticed that when the gridview scrollbar is dragged down, it tries to load all rows up the drag point and performance is very slow.

So, we have to either
1) Get the telerik gridview to work with our virtualization component
or
2) Get the telerik gridview to work with the  VirtualQueryableCollectionView, that takes our custom virtualization component as it's data source and maintains the same performance .

Once again many thanks for your help.
Subarna
0
Vlad
Telerik team
answered on 21 Jun 2011, 07:59 AM
Hello,

 I'm afraid that while our VirtualQueryableCollectionView can work in both cases (ListView and RadGridView) this approach (AsyncVirtualizingCollection) cannot work with RadGridView or even standard WPF DataGrid. 

I've attached however modified version of the project to illustrate you how VirtualQueryableCollectionView and RadGridView will work in this case.

Greetings,
Vlad
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Alan
Top achievements
Rank 1
answered on 01 Aug 2011, 04:09 PM
Hi,

Would it be possible to get a virtualization example solution using OpenAccess (SQL Db) to the RadGridView?

Ta. Al.
Tags
GridView
Asked by
Subarna Bandyopadhya
Top achievements
Rank 1
Answers by
Milan
Telerik team
Subarna Bandyopadhya
Top achievements
Rank 1
Vlad
Telerik team
Alan
Top achievements
Rank 1
Share this question
or