我究竟做错了什么?我收到以下错误。我正在使用 MVC,但没有使用 MVC 包装器。
Uncaught Error: Invalid template:'
<form action="/Intranet/GalleryFile/Edit" data-ajax="true" data-ajax-method="Post" data-ajax-mode="replace" data-ajax-update="#slideoutmenu" id="form1" method="post"> <input type="hidden" id="fileID" name="fileID" value='#= fileID #' />
<input type="submit" value="Save" class="btn btn-default" />
</form> ' Generated code:'var o,e=kendo.htmlEncode;with(data){o='\n<form action="/Intranet/GalleryFile/Edit" data-ajax="true" data-ajax-method="Post" data-ajax-mode="replace" data-ajax-update="';slideoutmenu" id="form1" method="post"> <input type="hidden" id="fileID" name="fileID" value=';o+='= fileID ';' />
<input type="submit" value="Save" class="btn btn-default" />
</form> ;o+=;}return o;'
JavaScript:
$(document).ready(function () {
var dsGalleryItemFile = new kendo.data.DataSource({
transport: {
read: "@Url.Content("~/Intranet/GalleryItemFile/ListFiles/")@Model.galleryItemID"
},
// determines if changes will be send to the server individually or as batch
batch: false,
schema: {
model: {
id: "fileID",
fields: {
fileID: {
nullable: true
},
filename: {},
fileType: { defaultValue: {fileTypeID: 1, fileType: "Web JPEG"} },
fileType: {},
width: { type: "number" },
height: { type: "number" },
}
}
}
});
$("#gvGalleryItemFile").kendoGrid({
columns: [{
field: "filepath",
title: "File Upload",
width:"250px",//,
//template: "<img src='#=filepath.filepath#' />"
}, {
field: "fileType",
title: "File Type",
template: "#=fileType.fileType#",
}, {
field: "width",
title: "Width(px)",
format: "{0:n0}",
width: "110px"
}, {
field: "height",
title: "Height(px)",
format: "{0:n0}",
width: "110px"
}, {
field: "fileID",
title: "",
template: kendo.template($("#gridEditButtonTemplate").html())
}],
dataSource: dsGalleryItemFile
});
});
模板:
<script type="text/x-kendo-template" id="gridEditButtonTemplate">
@using (Ajax.BeginForm("Edit", "GalleryFile", null, new AjaxOptions { UpdateTargetId = "slideoutmenu", InsertionMode = InsertionMode.Replace, HttpMethod = "Post" }))
{
<input type="hidden" id="fileID" name="fileID" value='#= fileID #' />
<input type="submit" value="Save" class="btn btn-default" />
}
</script>
这甚至没有达到 MVC 方面,所以我不包括该代码。它只是不会将模板读入我的网格列。