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

Grid in TabStrip within another Grid and 2 different models

1 Answer 113 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ralf
Top achievements
Rank 1
Ralf asked on 11 Jun 2014, 10:12 AM

Hello,

Let me explain my scenario for better understanding:
- my Model contains a list of products. All these products are displayed in GridView
- there is a nested detail template with TabStrip for each product
- one tab/item of this TabStrip contains all ebay auctions of this product in another GridView

ie. something like this http://demos.telerik.com/aspnet-mvc/grid/detailtemplate

My view in razor syntax:

@model List<Site.Models.Products>  // main model
[...]
 
@(Html.Kendo().Grid(Model)  // first grid which lists all products
    [...]
    .ClientDetailTemplateId("Details"// nested template
    [...]
 
<script id="Details">
    @(Html.Kendo().TabStrip()
    [...]
    .Items(items =>
    {
        [...]
        items.Add().Text("Auctions").Content(@<text>
            @(Html.Kendo().Grid(new List<Site.Models.EbayAuctions>())
            .Name("Auctions_for_#=strProductID#"// this variable is from Site.Models.Products
            .Columns(columns =>
            {
                columns.Bound(p => p.strEbayID); // this variable is from Site.Models.EbayAuctions
                [...]
Above example works fine! DataSources are read from Actions in my Controller.

But I don't want to display the strEbayID just like that, I want to display a link to the actual auction on the Ebay website.
The closest I got was this (replacing the above column):
.Columns(columns =>
{
    columns.Bound(p => p.strEbayID).ClientTemplate(
        "<a href=\"http://www.sandbox.ebay.com/itm/\">" + "#=data.strEbayID#" + "</a>"
    )
But unfortunately this doesn't work. To build the String I can use variables from the main model without a problem. But I don't know how I can use values from the nested model, ie. strEbayID here. It's displayed as undefined this way.

I couldn't solve this yet and I am running out of ideas. But I should be pretty close I guess. Can you help me?

With kind regards...

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 13 Jun 2014, 07:58 AM
Hello Ralf,

The "#" characters in a nested template should be escaped as demonstrated in this documentation topic:
columns.Bound(p => p.strEbayID).ClientTemplate(
        "<a href=\"http://www.sandbox.ebay.com/itm/\">" + "\\#=data.strEbayID\\#" + "</a>"
    )
Otherwise, the expression will be evaluated in the main template context.

Regards,
Daniel
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Ralf
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or