2017-10-20 16 views
0

我試圖通過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不是一個函數,但它應該。爲什麼它說這不是一個功能?

+0

當您添加kendo.all,所有的部件都已經添加,無需添加一個參考的TreeList來源。另外,如果文件正確加載,請重新檢查控制檯網絡選項卡。 – DontVoteMeDown

+0

這兩個加載罰款。即使我放棄了Kendo.All KendoTreeList仍然失敗@DontVoteMeDown與kendo.treelist正確加載 –

+0

何時何地調用SearchResults()'? – DontVoteMeDown

回答

0

問題是由於有一個以上的jQuery腳本參考引起的。 在MVC工作_Layout頁面下視圖 - >共享。當 - > _ Layout.cshtml有在底部@Scripts.Render("~/bundles/jquery")默認的參考。這需要刪除。擁有多個Jquery引用會導致腳本出現問題,導致編譯器無法找到您嘗試使用的函數。

相關問題