i have a problem with sorting and filtering. In my project i want to display a collection, in which are the items from different class type but have some same-named properties.
i.e.
ViewModelClassA : ViewModelBase
ViewModelClassB : ViewModelBase
ViewModelClassC : ViewModelBase
they all have the properties: Name, Description, Comment.
So i displayed this collection and want to use the sorting and filtering functions. Aber the filter and the sorting effect will not be shown.
I have tried to just take one type of my class, then everything is ok. I see the filter and the sorting effect.
Is there a discussion about this problem or even better there is already a solution for that? Thanks a lot!
Ivan
6 Answers, 1 is accepted
i upload a sample project.
http://project-free-upload.com/otknldzz7avk
Ivan
I am not able to download the project from the link. Would you please upload it in some other repository or open a new support thread and attach it there?
Regards,
Didie
Telerik
here is the project.
http://www.file-upload.net/download-9333864/RadGridView_WPF_AR_60.rar.html
Perhaps i have a solution. I'll build a container for the different ViewModels and pass the properties. Because in my project i cant abstract the properties in my base class.
Another problem - with CellTemplate i have also problem with sorting and filtering. I need some suggestion.
Thanks!
Ivan
I am again having a problem downloading the file, you can check the attached image. Would you please open a new support thread and attach the demo there?
Regards,
Didie
Telerik
i have removed folder bin and obj. Please try again, thanks.
http://www.file-upload.net/download-9376079/RadGridView_WPF_AR_60.rar.html
Thank you, it seems the .exe file in was blocked by my anti virus system. I run your solution and after adding an item of type ClubB, I am able to reproduce the issue.
Sorting and Filtering are data operations, they are actually done by building and executing a LINQ query over the source collection.
For example, when sorting on the Name property of the bound item, the generated query would be:
var result = viewSource.OrderBy(x => x.Name);
In your case the base class ClubBase do not have the respective properties (Name, Established and
StadiumCapacity) and that is why we cannot build and execute a query based on those properties over the list of ClubBase objects. That is why there is no filtering icon shown and the sorting and grouping are also not working
When all the items are of type ClubA, then RadGridView is smart enough to take ClubA as type of the items instead of ClubBase. When there are different type of items though, we cannot do so as we do not know which type to get.
You need to design your data so that you to be able to build and execute such a query.
Then, you can also specify the ItemType explicitly:
public
MainWindow()
{
InitializeComponent();
this
.clubsGrid.Items.ItemType =
typeof
(ClubBase);
}
Didie
Telerik