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

Issue on Grouped Row Click for VirtualQueryableCollectionView

3 Answers 55 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jacob
Top achievements
Rank 1
Jacob asked on 03 Oct 2016, 03:05 PM

Hello Telerik,

 

I am having a very strange issue when clicking on a row of a grouped grid populated by a VirtualQueryableCollectionView object

It turns out it duplicates itself.

I simulated it in the most simple solution I could think of. Check the attached pictures.

Please heIp me find a workaround for this issue.

The database I used contains only one table, having 4 rows on it.

And here is my code:

MainWindow.xaml

<Window x:Class="GroupingRowClickIssue.MainWindow"
        xmlns:local="clr-namespace:GroupingRowClickIssue"
                xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        mc:Ignorable="d"
        Loaded="Window_Loaded"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
 
        <telerik:RadGridView Name="RadGridView"  ItemsSource="{Binding View}"  AutoGenerateColumns="False" >
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn  DataMemberBinding="{Binding Name}"/>
                <telerik:GridViewDataColumn  DataMemberBinding="{Binding Type}"/>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
 
    </Grid>
</Window>

MainWindow.xaml.cs

using System.Windows;
using TelerikVirtualization;
 
namespace GroupingRowClickIssue
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
 
            DataContext = new ViewModel();
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ((ViewModel)DataContext).Load(); 
        }
    }
}

ViewModel.cs

using PropertyChanged;
using Telerik.Windows.Data;
 
namespace TelerikVirtualization
{
    [ImplementPropertyChanged]
    public class ViewModel
    {
        public VirtualQueryableCollectionView View { get; set; }
        Controller controller;
 
        public ViewModel()
        {
            controller = new Controller();
        }
        public void Load()
        {
            View = controller.GetUsers();
        }
    }
}

Controller.cs

using GroupingRowClickIssue;
using System.Data;
using System.Linq;
using Telerik.Windows.Data;
 
namespace TelerikVirtualization
{
    public class Controller
    {
        public VirtualQueryableCollectionView GetUsers()
        {
            DataClasses1DataContext db = new DataClasses1DataContext("Application Name=test;Data Source=WS-VRC;Initial Catalog=SimpleDB;User ID=sa;Password=App12345");
               
            var data = from item in db.SimpleTables
                       select new User
                       {
                           Name = item.Name,
                           Type = item.Type
 
                       };
 
            VirtualQueryableCollectionView view = new VirtualQueryableCollectionView(data) { LoadSize = 30, VirtualItemCount = data.Count() };
 
            return view;
        }
    }
    public class User
    {
        public string Name { get; set; }
        public string Type { get; set; }
 
    }  
}

 

 

3 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 05 Oct 2016, 02:18 PM
Hello Jacob,

Unfortunately, if you need to allow grouping of your data, you will need to go with another type of collection as grouping is not fully supported when using the VirtualQueryableCollectionView as grouping implies that all the data should be loaded beforehand, which breaks the conception of this mechanism. 

You could, for example, use the QueryableCollectionView class and provide an IQueryable as its source collection so that all operations will be executed directly on the server using the query provider.

Please let me know whether using the QueryableCollectionView would work for you.

Regards,
Dilyan Traykov
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Jacob
Top achievements
Rank 1
answered on 05 Oct 2016, 02:55 PM

Thank you for your answer, Dilyan.

Is there a way to convert the entire list from VirtualQueryableCollectionView to QueryableCollectionView right before grouping? If all data needs to be loaded for grouping, there is not much we can do, but to load it.

We just can't easily change the VirtualQueryableCollectionView, as our entire system is based on it.

0
Dilyan Traykov
Telerik team
answered on 07 Oct 2016, 01:14 PM
Hello Jacob,

Would it work for you to set the type of the View property in your view model to QueryableCollectionView and then set it in the Load method like so:

public void Load()
{
    this.View = new QueryableCollectionView(controller.GetUsers().QueryableSourceCollection);
}

Of course, you should use the same approach for your other collections as well.

Regards,
Dilyan Traykov
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Jacob
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Jacob
Top achievements
Rank 1
Share this question
or