2013-08-01 17 views
0

這裏是我的樹視圖:如何使用遠程數據將超鏈接配置到我的Kendo UI TreeView中?

function CreateNotificationTree(UserId) 
{ 
    var data = new kendo.data.HierarchicalDataSource({ 
     transport: { 
      read: { 
       url: "../api/notifications/byuserid/" + UserId, 
       contentType: "application/json" 
      } 
     }, 
     schema: { 
      model: { 
       children: "notifications" 
      } 
     } 
    }); 

    $("#treeview").kendoTreeView({ 
     dataSource: data, 
     loadOnDemand: true, 
     dataUrlField: "LinksTo", 
     checkboxes: { 
      checkChildren: true 
     }, 
     dataTextField: ["notificationType", "NotificationDesc"] 
    }); 
} 

我加了配置「dataUrlField」但我對如何配置dataTextField「NotificationDesc」是指被發現在API以及一個超鏈接不確定。

API "../api/notifications/byuserid/"帶回樹視圖的數據以及我需要的鏈接。這裏的API返回的內容:

<ArrayOfNode xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http....WebUI.Controllers" debug="true"> 
<script id="FirebugLite" firebugIgnore="true" extension="Chrome"/> 
<Node> 
    <notificationType>Edit Items</notificationType> 
     <notifications> 
     <Notification> 
      <ActionPageName>abc/ViewMembers.aspx</ActionPageName> 
      <ID>10285433</ID> 
      <NotificationDesc>2013 project</NotificationDesc> 
      <NotificationLink> 
       //the link I need is here 
      </NotificationLink> 
      <Params>...</Params> 
      </Notification> 
... 

回答

3

我想出如何做到這一點:

$("#treeview").kendoTreeView({ 
     dataSource: data, 
     loadOnDemand: true, 
     dataUrlField: "LinksTo", 
     checkboxes: { 
      checkChildren: true 
     }, 
     dataTextField: ["notificationType", "NotificationDesc"], 
     select: treeviewSelect 
    }); 

function treeviewSelect(e) 
    { 
     var node = this.dataItem(e.node); 
     window.open(node.NotificationLink, "_self"); 
    } 
相關問題