RadGridViewColumn filter is not working

0 Answers 266 Views
GridView
alex
Top achievements
Rank 2
Bronze
Iron
Iron
alex asked on 23 Apr 2023, 03:34 PM | edited on 01 May 2023, 07:33 PM

Hello, I have an issue with one column in the RadGridView.

I managed to bind a column to a value in the dictionary of my GridViewRow's DataContext.

Altought the filter icon appears, inside the list in the filter control I see only 1 item with the value "null", instead of the string values.

In the column itself, I can see all the values as expected.
I tried to set the DataMemberType/FilterMemberType to System.String, FilterMemberPath, add a converter that returns the string, and many other things that didn't work.

How can I filter this property?

The RadGridViewDataColumn is bound to a dictionary value on the DataMemberBinding property:
DataMemberBinding="{Binding MyDictionary[MyEnum.FirstValue].Title}"

Please see the "MyDemoProject.zip" example in the comments.

** Also sorting is not working. The sorting clears the RadGridRows, I think that it happens because of the same issue.

alex
Top achievements
Rank 2
Bronze
Iron
Iron
commented on 26 Apr 2023, 02:55 PM

any idea?
Stenly
Telerik team
commented on 26 Apr 2023, 04:59 PM

Hello Alex,

Could you share a bit more information about the structure of the classes and the way that you are binding the properties to the columns of the control? This will give me a general idea of the setup on your side, which I could isolate in a sample project and test this scenario.

alex
Top achievements
Rank 2
Bronze
Iron
Iron
commented on 26 Apr 2023, 10:57 PM | edited

Hello Stenly, I don't understand your question.

I wrote the exactly structure of classes: there is an enum usead as key in a dictionary and a collection (dictionary value) with one String property (Title). I want to show every collection in a column and have filter. I also wrote how I bound it, altough you can give me any other way to do it.

alex
Top achievements
Rank 2
Bronze
Iron
Iron
commented on 28 Apr 2023, 06:56 AM

Please if you kindly provide an answer I will appreciate it because I need to deliver the application to my client soon as possible
Stenly
Telerik team
commented on 01 May 2023, 01:41 PM

May I ask if you could give the FilterMemberPath property of the GridViewColumn column a try? It will allow you to specify, which property that will be used for the filtering logic of the column.

WPF DataGrid - Basic Filtering - Telerik UI for WPF

If this suggestion does not work, may I ask if you could modify the attached project to show the exact setup that is present on your end? This will allow me to review it on my side.

alex
Top achievements
Rank 2
Bronze
Iron
Iron
commented on 01 May 2023, 07:20 PM | edited

Hello Stenly,

Thank for your reply. I also tried FilterMemberPath and it is not working.

I updated the question because it was not clear that I have a collection of items with a dictionary property, so each row has a dictionary and each column is bound to a list (the dictionary item in the dictionary property of the row data context).

Please take a look at the attached project. It demonstrates the issue.

I want to have filter on the columns "TestFilter1", "TestFilter2", "TestFilter3".

You can notice that after adding 'FilterMemberPath' the filter shows [null],

The 'Title' property raises 'PropertyChanged' (the cell value is updated as expected) so the filter shall work.

I don't have any problem on accesing the dictionaries because the 'Count' column is bould on the same way and working as expected.

* Please check also the "Sorting" because it clears the RadGridView rows.

* I updated the dll's because I don't have a license at home, so I installed the trial version.

 

Best Regards,

Alex

alex
Top achievements
Rank 2
Bronze
Iron
Iron
commented on 04 May 2023, 08:07 PM

Dear Stenly, did you receive my answer and demo project?
alex
Top achievements
Rank 2
Bronze
Iron
Iron
commented on 09 May 2023, 06:26 PM

??
Stenly
Telerik team
commented on 12 May 2023, 11:57 AM

Hello Alex,

I have reviewed the sample project that you have prepared. However, a scenario where CLR and dynamic properties are used is not supported by RadGridView. This is because RadGridView's data layer used Queryable for operations like sorting, filtering, grouping, and searching. This layer will throw an error when creating the expression tree that will represent a data operation when it contains dynamic objects. Further information on this can be found in the last reply from the following feedback item:

GridView: Searching, Sorting, Filtering does not work properly when column is bound to a nested property of a dynamic property value (telerik.com)

What I could suggest in this scenario would be to change the setup of the objects. I have modified the sample project to show one approach for achieving this.

I hope the provided information will be of help to you.

alex
Top achievements
Rank 2
Bronze
Iron
Iron
commented on 12 May 2023, 09:24 PM | edited

Thank you Stenly for your reply and effort.

Unfortunetaly, I am not sure that this is the best solution for my case.

In my project is very important to have a dictionary and access by 'Key'. I don't want to add a public List and confuse the developers.

Having only a list, is not good enough because I want to have access by key and not by index.

I think that I will create another view model with a property for each dictionary value.

For example:

public FirstValueList {get;} = Dictionary[FirstValue];

Anyway, in case that we will add a new value for the enum in the future, we will add also a new column.

So now I will add a property too.

Thank you.

No answers yet. Maybe you can help?

Tags
GridView
Asked by
alex
Top achievements
Rank 2
Bronze
Iron
Iron
Share this question
or