2013-06-05 2 views
0

내가 원격 데이터 바인딩 KendoUI의 트 리뷰를 사용 이 아래에있는 내 코드는 다음 Taxonomys에
kendo.data.HierarchicalDataSource에서 할아버지의 데이터를 얻는 방법?

  <script> 
      var serviceRoot = "/kendoui"; 

      var Taxonomys = { 
       schema: { 
        model: { 
         id: "Name", 
         hasChildren: function() { 
          return false; 
         } 
        } 
       }, 
       transport: { 
        read: { 
         url: function (options) { 
          return kendo.format("http://localhost/MySite/MySiteService.svc/Organization/{1}/Project/{0}/Taxonomy?includeSchema=0", options.Name); 
         } 
        } 
       } 
      }; 

      var Projects = { 
       schema: { 
        model: { 
         id: "Name", 
         hasChildren: function() { 
          return true; 
         }, 
         children: Taxonomys 
        } 
       }, 
       transport: { 
        read: { 
         url: function (options) { 
          return kendo.format("http://localhost/MySite/MySiteService.svc/Organization/{0}/Project", options.Name); 
         } 
        } 
       } 
      }; 

      homogeneous = new kendo.data.HierarchicalDataSource({ 
       transport: { 
        read: { 
         url: "http://localhost/MySite/MySiteService.svc/Organization ", 
         dataType: "jsonp" 
        } 
       }, 
       schema: { 
        model: { 
         id: "Name", 
         hasChildren: function() { 
          return true; 
         }, 
         children: Projects 
        } 
       } 
      }); 

      $("#treeview").kendoTreeView({ 
       dataSource: homogeneous, 
       dataTextField: ["Name", "Name", "Name"] 
      }); 
     </script> 

, 나는 조직 이름이 필요합니다.

http://localhost/MySite/MySiteService.svc/Organization/{1}/Project/{0}/Taxonomy?includeSchema=0 

"url : function (options) {}"의 옵션에는 Projects 이름 만 있습니다. 프로젝트의 학부모 이름은 어떻게 얻을 수 있습니까?

답변

0

트리의 노드를 지정하면 parent 트리를 탐색하는 방법을 사용해야합니다.

예. 우리가 선택한 노드의 조부모를 얻고 싶은 경우에 우리는 사용한다 :

var select = treeview.select(); 
console.log("select", select); 
if (select.length) { 
    var parent = treeview.parent(select); 
    if (parent.length) { 
     console.log("parent", treeview.dataItem(parent)); 
     var grandparent = treeview.parent(parent); 
     if (grandparent.length) { 
      console.log("grandparent", treeview.dataItem(grandparent)); 
     } else { 
      console.log("has no grandfather") 
     } 
    } else { 
     console.log("has no father") 
    } 
} else { 
    console.log("select a node"); 
} 

당신은 내가 그 아버지를 가지고, 선택된 노드가 있다는 것을 확인하는 유효성 검사를하고있어 볼 수 있습니다 그것은 할아버지가 기본.

해당 항목의 데이터도 표시됩니다. 이것으로 당신은 모델의 일부인 조직과 프로젝트를 얻을 수 있어야합니다. 나는 전송에서 할 수있는 방법

+0

: { 읽기 : { URL : 기능 (옵션) { 반환 kendo.format ("HTTP : //localhost/MySite/MySiteService.svc/Organization/ {1}/프로젝트/{0}/Taxonomy? includeSchema = 0 ", options.Name); } } } – user2454489

+0

확장되는 노드에서 정보를 얻는 방법에 대한 질문이 있습니까? – OnaBai

+0

예. 원격 데이터에 바인딩 – user2454489