1

我想为 ListView 创建一个自定义模板(我在 ListView 中显示产品 eShop)。我写了这段代码:

<script type="text/x-kendo-tmpl" id="template">
    <div class="item">
    <div class="image">
        <a href='@Url.Action("GetDetails", "Products", routeValues: new {id =${ProductID}} )' target='_blank' class='pimg'>
            <img src="${ProductThumbnailImageUrl}" alt=" ${ProductTitle}"/>
        </a>
    <div class="price"> ${kendo.toString(ProductPrice, "n0")} </div>

    <div class="name">

</div>
    <div class="description_featured" style="min-height: 110px;">
        ${ProductDescription}

    </div>
    </div>
</div>

</script>

@(Html.Kendo().ListView(Model)
          .Name("listView")
          .TagName("div")
          .ClientTemplateId("template")
          .DataSource(dataSource =>
                      {
                          dataSource.Read(read => read.Action("Products_Read", "Products"));
                          dataSource.PageSize(12);
                          dataSource.ServerOperation(false);
                      })
          .Pageable()
             )

我收到一个错误new {id = ${ProductTitle}}

4

1 回答 1

3

这就是您使用模板的方式。这是我最近用于我的网站的模板中的一个。

<script type="text/x-kendo-tmpl" id="template">
       <div class="product">
            <img src='http://cdn.rbgx.net/images/skybazaar/products/medium/${ImageFileName}' alt="${Name} image" />
    <div class="productDeatails">
            <h3>#:Name#</h3>
     # if (EntityType == 2) { #
        Click to see products of this category
    # } else if(EntityType == 1) { #
     # if(parseFloat(SalePrice) > 0 && parseFloat(SalePrice) < parseFloat(Price)) { #
    Sale Price #: kendo.toString(SalePrice, "c")#
    # } else { #
     Price #: kendo.toString(Price, "c")#
    # } #
    # } #
        </div>
        </div>
    </script>

在你的情况下${ProductTitle} 使用#: ProductTitle #

于 2013-04-15T14:37:26.240 回答