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

RowTemplate with cells each has its own template

2 Answers 54 Views
Grid
This is a migrated thread and some comments may be shown as answers.
HSO
Top achievements
Rank 2
HSO asked on 09 Apr 2013, 10:30 AM
Hello:

Here is the Razor view of Grid declaration:

@(Html.Kendo().Grid(Model)
.Name("grid")
.Columns(cols =>
{
    cols.Bound(c => c.OrgID).Template(e => { });
    cols.Bound(c => c.UserID);
    cols.Bound(c => c.IsAssigned);
 
})
.RowTemplate(@<text>
@item.OrgName<br />
@item.City, @item.ProvinceText, @item.CountryText
 
</text>)
 
)
There are 3 columns, the one currently in RowTemplate only applies to the 1st column, I also need the 2nd column to be 'templated', which shows a photo and name of the User (accessable by @item.ImgURL, @item.FullName).
I am not sure how to do that, because if I put <tr> or <td> within RowTemplate @<text> block, it complains that those elements cannot be nested.  if I don't have <tr> or <td>, the html output puts colspan="3", so no way for me to come up 3 column structure.

Please advise,

Thank you,

2 Answers, 1 is accepted

Sort by
0
Accepted
Vladimir Iliev
Telerik team
answered on 11 Apr 2013, 08:10 AM
Hi Jason,


In current scenario where you need to keep the original layout of the table I would suggest to use column Template method instead of RowTemplate and render the required items inside each column:

columns.Bound(p => p.ProductName).Template(@<text>
    <strong>ProductID: @item.ProductID</strong>
    <p>@item.ProductName</p>
</text>);

Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
HSO
Top achievements
Rank 2
answered on 12 Apr 2013, 03:47 PM
ok, got it.  Thank you!
Tags
Grid
Asked by
HSO
Top achievements
Rank 2
Answers by
Vladimir Iliev
Telerik team
HSO
Top achievements
Rank 2
Share this question
or