0

我试图将行模板应用于网格,但未显示数据......我从一个非常简单的模板开始,之后我将对其进行自定义。

到目前为止我所拥有的:

@(Html.Kendo().Grid<MyProject.Models.StudentCF>().
Name("Grid")
.Columns(columns =>
{
    columns.Bound(p => p.FirstName);
    columns.Bound(p => p.LastName);
    columns.Bound(p => p.Age);
    columns.Bound(p => p.Course);
    columns.Bound(p => p.School.Name);
})
.DataSource(dataSource => dataSource
    .Ajax()
    .Read(read => read.Action("IndexJsonCF", "StudentCF"))
)
.Selectable()
.AutoBind(true)
.Filterable()
.Groupable()
.Sortable()
.Pageable(pager =>
{
    pager.Input(true);
    pager.Messages(messages => messages.Display("Showing items from {0} to {1}. Total items: {2}"));
    pager.PageSizes(new int[]{5,10,20,50,100,1000});
    pager.Refresh(true);
})
.ClientRowTemplate("rowtemplate")
)

<script type="text/x-kendo-template" id="rowtemplate">
    "<tr>" +
        "<td>" +
           "#= FirstName#" +
        "</td>" +
        "<td>" +
           "#= LastName#" +
        "</td>" +
        "<td>" +
            "#= Age#" +
        "</td>" +
        "<td>" +
            "#= Course#" +
        "</td>" +
        "<td>" +
            "#= School.Name#" +
        "</td>" +
     "</tr>" 
</script>

网格中显示的只是带有模板 id 的一行rowtemplate(重复)

我错过了什么?

更新 我想做这样的事情:ClientRowTemplate(),但似乎这是不可能的......

4

1 回答 1

0

这是将行模板应用于网格的代码,但要确保 FirstName 等字段有效。所以只需在此处删除字符串并编写简单的 HTML。

<script type="text/x-kendo-template" id="rowtemplate">
<tr>
    <td>
       #= FirstName#
    </td>
    <td>
       #= LastName#
    </td>
    <td>
        #= Age#
    </td>
    <td>
        #= Course#
    </td>
    <td>
        #= School.Name#
    </td>
 </tr> 
 </script>
于 2013-04-10T13:34:53.050 回答