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
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
4 Answers, 1 is accepted
0
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
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.
0
Oleg
Top achievements
Rank 1
answered on 31 Jul 2014, 07:57 PM
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...
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;
}
}
0
Oleg
Top achievements
Rank 1
answered on 31 Jul 2014, 08:00 PM
And also there is a xaml, nothing special in it.
<
Window
x:Class
=
"TelerikTest.MainWindow"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
Title
=
"MainWindow"
Height
=
"350"
Width
=
"525"
>
<
Grid
>
<
telerik:RadGridView
x:Name
=
"RadGridView"
>
</
telerik:RadGridView
>
</
Grid
>
</
Window
>
0
Hi,
As you have a demo solution, would you please open a new support ticket and attach it there?
Regards,
Didie
Telerik
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.