RadGridView + QueryableDataProvider: sorting for fields that are not in groups doesn't work

5 posts, 0 answers
  1. Oleg
    Oleg avatar
    3 posts
    Member since:
    May 2014

    Posted 30 Jul 2014 Link to this post

    Hello All.
    I've a scenario when I use RadGridView linked with QueryableDataProvider.
    QueryableDataProvider accepts IQueryable linked with DBContext.
    In RadGridView in UI I did groping by one column and sorting by another column

    class A : TEntity
    {
        public string P1;
        public string P2;
    }

    Group by P1 and sort by P2 over UI.

    In case, IQueriable points to in memory collection, everything works fine.
    But when IQueriable points to IDbSet<TEntity> - sorting is not applied.
    One difference between my tests is in "ToList()" called on IQueriable passed to QueryableDataProvider constructor.
    Unfortunately, I cannot use InMemory collection.
    Telerik version is 2014.1.331.45
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 31 Jul 2014 Link to this post

    Hello,

    The sorting is a data operations. This is how RadGridView is designed to work and sorting is actually done by building and executing a LINQ query over the source collection. 

    So, if you can build such a LINQ query appending OrderBy clause based on the DataMemberBinding or the SortMemberPath set for a column, then RadGridView will also be able to sort the respective column. Otherwise, this will not be possible.

    It seems your source does not allow this and that is why the sorting does not work.


    Regards,
    Didie
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. Oleg
    Oleg avatar
    3 posts
    Member since:
    May 2014

    Posted 31 Jul 2014 in reply to Dimitrina Link to this post

    Hello.
    Thank you for you reply, Didie.
    I can build such a LINQ query appending OrderBy clause.
    I've prepared simple solution to show, what I mean, but I cannot attach it there...
    Any way, I did screenshots, it's in attachment, and I'll try to posts all the code right here...

    public partial class MainWindow : Window
        {
            private TestEntities testEntities;
     
            public MainWindow()
            {
                this.InitializeComponent();
                // EmployeeService.Install();
                this.testEntities = new TestEntities(EmployeeService.ConnectionString);
                this.RadGridView.ItemsSource = new QueryableCollectionView(this.testEntities.Set<Employee>());
            }
        }


    public class TestEntities : DbContext
        {
            public TestEntities(string connectionString)
                : base(connectionString)
            {
            }
     
            protected override void OnModelCreating(DbModelBuilder modelBuilder)
            {
                modelBuilder.Entity<Employee>().ToTable("Employee");
            }
        }


    public class EmployeeService
        {
            public const string ConnectionString = "Test1";
     
            public static void Install()
            {
                var employees = GetEmployees();
                using (var testEntities = new TestEntities(ConnectionString))
                {
                    var set = testEntities.Set<Employee>();
                    foreach (var employee in employees)
                    {
                        set.Add(employee);
                    }
     
                    testEntities.SaveChanges();
                }
            }
     
            private static IEnumerable<Employee> GetEmployees()
            {
                var employees = new List<Employee>();
                var employee = new Employee { FirstName = "Maria", LastName = "Anders", IsMarried = true, Age = 24 };
                employees.Add(employee);
                employee = new Employee { FirstName = "Ana", LastName = "Trujillo", IsMarried = true, Age = 44 };
                employees.Add(employee);
                ........
                return employees;
            }
        }


  4. Oleg
    Oleg avatar
    3 posts
    Member since:
    May 2014

    Posted 31 Jul 2014 in reply to Dimitrina Link to this post

    And also there is a xaml, nothing special in it.
    <Window x:Class="TelerikTest.MainWindow"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <telerik:RadGridView x:Name="RadGridView" >
            </telerik:RadGridView>
        </Grid>
    </Window>
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 01 Aug 2014 Link to this post

    Hi,

    As you have a demo solution, would you please open a new support ticket and attach it there?

    Regards,
    Didie
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top