我正在搞乱Kendo UI。我试图在模板中添加一些JavaScript代码,网格不会呈现。
这是行模板代码:
<script id="dlRowTemplate" type="text/x-kendo-tmpl">
<tr>
<td class="details">
<span class="title"><a href="#: link#">#: title#</a></span>
<span class="description">Airdate: #: airdate#</span>
</td>
<td class="ID">
<a onClick="OpenInNewTab('url=#: modifiedtext#')">DL NZB</a>
</td>
</tr>
</script>
<script id="altdlRowTemplate" type="text/x-kendo-tmpl">
<tr>
<td class="details">
<span class="title"><a href="#: link#">#: title#</a></span>
<span class="description">Airdate: #: airdate#</span>
</td>
<td class="ID">
<a onClick="OpenInNewTab('http://url=#: modifiedtext#')">DL NZB</a>
</td>
</tr>
</script>
这是表格HTML代码
<table id="dl_grid">
<colgroup>
<col class="details"/>
<col />
</colgroup>
<thead>
<tr>
<th>
Details
</th>
<th>
ID
</th>
</tr>
</thead>
</table>
以下是在标签中设置网格的代码
$("#dl_grid").kendoGrid({
dataSource: {
transport: {
read: "include/showstuff.php"
},
schema: {
data: "data"
}
},
rowTemplate: kendo.template($("#dlRowTemplate").html()),
altRowTemplate: kendo.template($("#altdlRowTemplate").html()),
height: 430
});
按下按钮并调用php页面来获取数据(在标签中)时调用数据:
$("#view").on('submit', function(e) {
e.preventDefault();
var textVal = $("#cmb").val();
var dynamicURL = "include/showstuff.php?id=" + textVal;
var grid = $("#dl_grid").data("kendoGrid");
grid.dataSource.transport.options.read.url = dynamicURL;
grid.dataSource.read();
});
提前致谢。