This is a migrated thread and some comments may be shown as answers.

Sorting and filtering failure on binding path as (Object or dynamic Type).Name"

3 Answers 193 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Huan jia
Top achievements
Rank 1
Iron
Huan jia asked on 14 Feb 2021, 05:34 PM

  <telerik:RadTreeListView.ChildTableDefinitions>
                <telerik:TreeListViewTableDefinition ItemsSource="{Binding Children}" />
            </telerik:RadTreeListView.ChildTableDefinitions>
            <telerik:RadTreeListView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=Item.Name}" Header="Name" SortMemberPath="Item.Name" DataType="{x:Type sys:String}"  />

            </telerik:RadTreeListView.Columns>

    public class Node
    { 
        public object Item { get; set; }

        //public WarehouseItem Item { get; set; } this line works fine

        public ObservableCollection<Node> Children { get; set; } = new ObservableCollection<Node>();
    }

 

If my Node.Item is object or dynamic type, sorting and filtering do not work, if it is a specific entity type like WarehouseItem they works fine.

The same thing happens to RadGridView.

3 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 17 Feb 2021, 12:54 PM

Hello Huan,

Thank you for the provided code snippets.

As the underlying data engine of both the RadTreeListView and RadGridView (which both inherit the GridViewDataControl class) relies on the type of the bound objects, it cannot get ahold of the required property if the type in question does not expose such a public member.

What I can suggest in such a case is to create an interface to hold the properties which will be displayed in the columns and ensure that the items bound to the control inherit this interface. For example:

    public interface IName
    {
        string Name { get; set; }
    }
    public class Node
    { 
        public IName Item { get; set; }

        //public WarehouseItem Item { get; set; } this line works fine

        public ObservableCollection<Node> Children { get; set; } = new ObservableCollection<Node>();
    }
Please let me know whether such an approach would work for you.

Regards,
Dilyan Traykov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Huan jia
Top achievements
Rank 1
Iron
answered on 20 Feb 2021, 05:31 AM

Hi Dilyan, I can't hold the specific properties. My entity object is inherited from DynamicObject and the specific properties are defined in Database.

I think you can get ahold of properties, because if the DataContext is DynamicObject and path is "Name" rather than "Item.Name", the sorting and filtering is OK. 

0
Dilyan Traykov
Telerik team
answered on 24 Feb 2021, 12:28 PM

Hi Huan,

I've come across the following bug report which seems to be related to the same issue you experience.

The reason behind this issue is a limitation in our current implementation of RadGridView's data engine. Generally, it has two independent modules that handle CLR and DLR properties, as the .NET framework does not provide out-of-the box parity to suit our needs. Thus when RadGridView detects a dynamic type, it uses a DynamicExpressionFactory to build the needed data access expressions. However, it fails to resolve nested CLR properties of the dynamic properties, as it uses the LINQ dynamic member API (Expression.Dynamic) to build the expression.

I updated the bug entry by adding your case to it. You can subscribe to the public item to track our progress with it. I'm afraid, however, that I cannot commit to a certain time-frame for a fix at this point.

If I can, however, further assist you with anything else in the meantime, please let me know.

Regards,
Dilyan Traykov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
TreeListView
Asked by
Huan jia
Top achievements
Rank 1
Iron
Answers by
Dilyan Traykov
Telerik team
Huan jia
Top achievements
Rank 1
Iron
Share this question
or