Issue on Grouped Row Click for VirtualQueryableCollectionView

4 posts, 0 answers
  1. Jacob
    Jacob  avatar
    24 posts
    Member since:
    Apr 2016

    Posted 03 Oct Link to this post

    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; }
     
        }  
    }

     

     

  2. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    371 posts

    Posted 05 Oct Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Jacob
    Jacob  avatar
    24 posts
    Member since:
    Apr 2016

    Posted 05 Oct in reply to Dilyan Traykov Link to this post

    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.

  5. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    371 posts

    Posted 07 Oct Link to this post

    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.
Back to Top