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

Grid with nested object in VM

1 Answer 61 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ITsolution
Top achievements
Rank 1
Iron
ITsolution asked on 07 Jan 2021, 12:27 PM

Hello,

 

in C# I've got 2 ViewModels:

```

public class TestListViewModel

{

    public string Param { get; set; }

    public IEnumerable<TestViewModel> Counts { get; set; }

}

```

 

```

public class TestViewModel

{

    public string Name { get; set; }

    public int Count { get; set; }

}

```

 

now I will pass IEnumerable<TestListViewModel> as model to grid. How can I get the result like this: https://demos.telerik.com/aspnet-mvc/grid/aggregates?

I don't need to aggregate any data because it's already done. I just need to fill this grid somehow.

It's my local data, so the Grid will starts with:

```

@(Html.Kendo().Grid(Model)

    .Name("grid")

    .Columns(columns => (?))

    (...)

)

```

1 Answer, 1 is accepted

Sort by
0
Anton Mironov
Telerik team
answered on 11 Jan 2021, 11:26 AM

Hello John,

Thank you for the provided code snippet.

In order to achieve the desired behavior, I would recommend using the implementation from the following demo:

Click at the View Source tab and observe the implementation for binding the Kendo UI Grid to local data.

Give the approach above a try and let me know if further assistance is needed.

 

Kind Regards,
Anton Mironov
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
Grid
Asked by
ITsolution
Top achievements
Rank 1
Iron
Answers by
Anton Mironov
Telerik team
Share this question
or