2014-04-04 46 views
0

我面臨的一個問題,下面的代碼綁定樹第一次,但不工作的第二次結合的樹:(但是當我要求三分之一的綁定一次。KendoUI TreeView控件綁定問題

意味着即使是要求工作。

請幫我

在此先感謝

Mobeen

//我的示例數據

{ 「d」:[{ 「_ 類型」: 「ManageUPPRM.UserDocumentDTO」, 「DocumentID」:1804105651, 「DocumentName」: 「谷歌講座」, 「hasChildren」:真正},{ 「 _type」 : 「ManageUPPRM.UserDocumentDTO」, 「DocumentID」:15854591701, 「DocumentName」: 「的desktop.ini」, 「hasChildren」:假},{ 「__類型」: 「ManageUPPRM.UserDocumentDTO」, 「DocumentID」:15861429553, 「DocumentName」 : 「Jellyfish.jpg」, 「hasChildren」:假}]}

//代碼

var datasource = new kendo.data.HierarchicalDataSource({ 
       transport: { 
        read: function (options) { 
         var id = options.data.DocumentID; 

         if (typeof id == "undefined") { 
          id = "0" 
         } 

         $.ajax({ 
          type: "POST", 
          url: "../ManageUPWebService.asmx/GetAllDocuments", 
          dataType: "json", 
          contentType: "application/json; charset=utf-8", 
          data: "{DocumentID:'" + id + "'}", 
          success: function (result) { 
           // notify the data source that the request succeeded 
           options.success(result.d); 
          }, 
          error: function (result) { 
           // notify the data source that the request failed 
           options.error(result.d); 
          } 
         }); 
        } 
       }, 
       schema: { 
       model: { 
         id: "DocumentID", 
         text: "DocumentName", 
         hasChildren: "hasChildren" 
        } 
       } 
      }); 

      $("#treeview").kendoTreeView({ 

       checkboxes: { 
        checkChildren: true, 
        template: "<input type='checkbox' name='#=item.id#' data-text='#=item.DocumentName#' value='true' />" 
       }, 

       loadOnDemand: true, 
       dataSource: datasource, 
       dataTextField: "DocumentName" 
      }); 
+0

一段時間我看到控制檯錯誤錯誤之前:遺漏的類型錯誤:無法調用未定義 – user3496681

+0

「設定」不呼叫時,每次要到服務器你請求json數據 –

+0

你可以嘗試創建重現它的JSFiddle/JSBin嗎? – OnaBai

回答

2

試試這個, 一些ID添加一個div爲樹狀

的父DIV
<div id="parent"><div id="treeview"></div></div> 

,並結合劍道樹

$("#treeview").remove(); 
$("<div id=\"treeview\" />").appendTo("#parent").kendoTreeView({ 
      checkboxes: { 
       checkChildren: true, 
       template: "<input type='checkbox' name='#=item.id#' data-text='#=item.DocumentName#' value='true' />" 
      }, 

      loadOnDemand: true, 
      dataSource: datasource, 
      dataTextField: "DocumentName" 
     }); 
+0

感謝Rudresh,結合現在的工作,但現在我面臨的新問題,當我取消選擇按鈕treeview複選框不更新他的狀態。 – user3496681

+0

什麼狀態不更新?你可以更清楚 –

+0

如果我以編程方式更改選中複選框取消選中使用jquery,它不更新樹視圖控件中複選框的狀態。 – user3496681