Telerik的jQuery的KendoTreeList不是一个函数
问题描述:
我试图通过jQuery来使用kendoTreeList的功能。该Tekerik文档是在这里: https://docs.telerik.com/kendo-ui/api/javascript/ui/treelistTelerik的jQuery的KendoTreeList不是一个函数
我使用的代码如下所示:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="~/Scripts/jquery-1.12.4.js"></script>
<script src="@Url.Content("~/Scripts/kendo/kendo.all.min.js")"></script>
<script src="@Url.Content("~/Scripts/kendo/kendo.treelist.min.js")">
</script>
<script>
var search = document.getElementById("SearchTerm");
function SearchResults(results) {
$('#ResultsList').empty();
var items = {};
$.each(results, function (i, value) {
items += { id: i, parentId: null, Name: value.MacroName, Type:"Macro" }
if (value.Files.length > 0) {
$.each(value.Files, function (x, File) {
items += {parentId: i, Name: File, Type:"File"}
});
}
if (value.Servers.length > 0) {
$.each(value.Services, function (x, Server) {
items += { parentId: i, Name: Server, Type: "Server" }
});
}
if (value.Databases.length > 0) {
$.each(value.Databases, function (x, DB) {
items += { parentId: i, Name: DB, Type: "Databases"}
});
}
if (value.Services.length > 0) {
$.each(value.Services, function (x, Service) {
items += { parentId: i, Name: Service, Type: "Service" }
});
}
if (value.SecGroups.length > 0) {
$.each(value.SecGroups, function (x, PSI) {
items += { parentId: i, Name: PSI, Type: "SecGroup" }
});
}
});
$("#ResultsList").kendoTreeList({
columns: [
{ field: "Name" },
{ field: "Type"},
{
command: [{
name: "Display",
text: "Display",
click: function (e) {
// e.target is the DOM element representing the button
var tr = $(e.target).closest("tr"); // get the current table row (tr)
// get the data bound to the current table row
var data = this.dataItem(tr);
console.log("Details for: " + data.Name);
Display(data.Name, data.Type)
}
}]
}
],
editable: true,
dataSource: items
});
}
function Display(value,Type)...
</script>
还有更多的代码,但搜索结果是所有的必要的,它包含了kendoTreeList功能。调试器说.kendoTreeList不是一个函数,但它应该。为什么它说这不是一个功能?
答
问题是由于有一个以上的jQuery脚本参考引起的。 在MVC工作_Layout
页面下视图 - >共享。当 - > _ Layout.cshtml有在底部@Scripts.Render("~/bundles/jquery")
默认的参考。这需要删除。拥有多个Jquery引用会导致脚本出现问题,导致编译器无法找到您尝试使用的函数。
当您添加kendo.all,所有的部件都已经添加,无需添加一个参考的TreeList来源。另外,如果文件正确加载,请重新检查控制台网络选项卡。 – DontVoteMeDown
这两个加载罚款。即使我放弃了Kendo.All KendoTreeList仍然失败@DontVoteMeDown与kendo.treelist正确加载 –
何时何地调用SearchResults()'? – DontVoteMeDown