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

Grid with column template

1 Answer 231 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mikael
Top achievements
Rank 2
Mikael asked on 05 Feb 2013, 08:16 AM
Hello, first time posting here so Hi to everyone on the forums.
I'm currently evaluating Kendo for use in a asp.net mvc4 web application using razor based views. As usual I started with trying to figure out the "hard part" first, how well Kendo handles ManyToMany relationships in models. And instantly i was positively greeted with a list of all the foreign key id's in the column. So far so good.
After some fiddling and some reading i figured that the use of a .Template would be the way to go to display the actual information and not just the Id's. Maybe I just havent understood the syntax of the templates yet, I'v only been looking at this for a few hours still. 
What I'v tried is something like this:
columns.Bound(m => m.Departments).Template(m =>
{
  foreach (var department in m.Departments)
  {
    @<text> @department.Name @</text>;
  }
});
The data in the Model is all there and in order.
Obviously this isn't working, and I'v tried a few combinations of output that i'v found on these forums but none seem to work for me.
Can anyone offer some assistance towards the proper way of achieving this?

Br.

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 07 Feb 2013, 07:44 AM
Hello Mikael,

The syntax will be a little different e.g.

columns.Bound(m => m.Departments).Template(@<text>
    @foreach (var department in item.Departments)
    {
        @department.Name
    }
 
</text>);
I would recommend to check the following blog posts which provide information about the Razor syntax: Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Mikael
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Share this question
or