Unplanned
Last Updated: 19 Jul 2021 12:05 by ADMIN
Mike
Created on: 19 Jul 2021 12:01
Category: Grid
Type: Feature Request
0
Provide built-in support and parsing related to properties of nested objects

Currently a DateTime property of a nested object does not get parsed when used as a column in the Grid:

public class MyClass
{
   public MyOtherClass Item{get;set;}
}

public class MyOtherClass
{
    public DateTime CreatedAt{get;set;}
}

and Formatting cannot be applied:

 columns.Bound(p => p.Item.CreatedAt).Title("Time").Format("{0:D}");

 

1 comment
ADMIN
Aleksandar
Posted on: 19 Jul 2021 12:05

Hello Mike,

Thank you for the valuable feedback. Indeed this is a valid Feature request as currently when a complex object is passed to the Grid it's properties are not parsed, but are passed as-is.

Until such feature is implemented you can define a DataSource.Scheme.Parse function and ensure the model property is parsed:

            .DataSource(dataSource => dataSource
                .Custom()
                .PageSize(20)
                .Transport(t=>t.Read(read => read.Action("MyAction", "MyController")))
                .Schema(s=> {
                    s.Parse(@<text>function parse(args){return handleResponse(args);}</text>);
                    s.Data("Data");
                    s.Total("Total");
                })
             )
        )

<script>
    function handleResponse(response) {
        var parsedResponse= response;
        for (var i = 0; i < resp.Data.length; i++) {
            resp.Data[i].MyParentObject.Item.CreatedAt = kendo.parseDate(resp.Data[i].MyParentObject.Item.CreatedAt)
        }
        return parsedResponse;
    }
</script>

Regards,
Aleksandar
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/.