如何在Kendo UI网格中使用外部clienttemplate(使用嵌套模板)

时间:2014-03-26 15:30:50

标签: javascript asp.net-mvc kendo-ui kendo-grid

我的客户端模板开始非常大,我希望能够将其放入<script>

我的两个问题是:

  • 如何将外部脚本设置为clientTemplate?
  • 如何将其他脚本/模板嵌套到我的主模板中。

以下是我现在想要改变的内容:

    @(Html.Kendo().Grid<Car>()
              .Name("testGrid)
              .BindTo(Model.CarList)
              .Columns(columns =>
              {

                  columns.Bound(a => a.CarInitialAndNumber)
                      .Width(150)
                      .IncludeInMenu(false)
                      .HtmlAttributes(new { title = "#=CarInitialAndNumber#" })

                      .ClientTemplate(
                          "#=CarInitialAndNumber# <span role=\"menuitem\" class='glyphicon glyphicon-plus jqtooltip k-header-column-menu' " +
                          "title='<table class=\"uitooltip\">" +
                          "<tr><td><span>" + Resources.CarGrid_Column_CCO + ":</span></td><td>#=CCO#</td><td><span>" + Resources.CarGrid_Column_Length + ":</span></td><td>#=Length#</td></tr>" +
                          "<tr><td><span>" + Resources.CarGrid_Column_NetWeight + ":</span></td><td>#=NetWeight#</td></tr>" +
                          "<tr><td><span>" + Resources.CarGrid_Column_Pool + ":</span></td><td>#=Pool#</td><td><span>" + Resources.CarGrid_Column_Shipper + ":</span></td><td>#=Shipper#</td></tr>" +
                          "<tr><td><span>" + Resources.CarGrid_Column_Origin + ":</span></td><td colspan=\"3\">#=OriginFacility#</td></tr></table>'" +
                          " style='float:right;line-height:10px;margin-top:4px'></span>"
                      )
                      .Title(Resources.CarGrid_Column_CarInitialNumber);


             })
             .DataSource(dataSource => dataSource
                         .Ajax()
                         .Read(read => read.Action("GetCars", "controller").Data("getCriteria"))
                  )
             .Events(o => o.DataBound("onCarDatabound"))

但是我想把它放在那样的东西(2个不同的模板.1用于容器,另一个用于工具提示。):

<script id="detail-template" type="text/x-kendo-template">
    #=CarInitialAndNumber#
    <span role="menuitem" class='glyphicon glyphicon-plus jqtooltip k-header-column-menu'
          title="#=UseToolTipTemplate#"
          style="float:right;line-height:10px;margin-top:4px">
    </span>
</script>

<script id="detailtooltip-template" type="text/x-kendo-template">
<table class="uitooltip">
    <tr>
        <td>
            <span>@(Resources.CarGrid_Column_CCO) :</span>
        </td>
        <td>#=CCO#</td>
        <td>
            <span>@(Resources.CarGrid_Column_Length) :</span>
        </td>
        <td>#=Length#</td>
    </tr>
    <tr>
        <td>
            <span>@(Resources.CarGrid_Column_NetWeight) :</span>
        </td>
        <td>#=NetWeight#</td>
    </tr>
    <tr>
        <td>
            <span>@(Resources.CarGrid_Column_Pool) :</span>
        </td>
        <td>#=Pool#</td>
        <td>
            <span>@(Resources.CarGrid_Column_Shipper) :</span>
        </td>
        <td>#=Shipper#</td>
    </tr>
    <tr>
        <td>
            <span>@(Resources.CarGrid_Column_Origin) :</span>
        </td>
        <td colspan="3">#=Origin#</td>
    </tr>
</table>
</script>

我只是不知道如何将此特定clientTemplate的值设置为我脚本中的值。

0 个答案:

没有答案