c# - 如何使用远程数据将超链接配置到我的 Kendo UI TreeView 中?

标签 c# javascript asp.net kendo-ui kendo-treeview

这是我的 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/” 带回 Treeview 的数据以及我需要的链接。以下是 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>
...

最佳答案

我知道怎么做了:

$("#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");
    }

关于c# - 如何使用远程数据将超链接配置到我的 Kendo UI TreeView 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18005446/

相关文章:

c# - 用于 C# SlimDX 游戏 UI 的内容

c# - 从 C# 程序中反序列化 JSON 时,我是否需要使用 JavaScriptSerializer 以外的任何东西?

JavaScript 数组解构

javascript - DOMContentLoaded 事件中的代码不起作用

javascript - 带yield的条件赋值

c# - Page.ClientScript.RegisterStartupScript 不起作用 - 为什么?

asp.net - 如何使用jquery实现滑动效果

c# - 通用 Property.GetSetMethod 的委托(delegate)

c# - 专注于应用程序时无法显示任务栏

c# - 发布 Web 应用程序时 AfterPublish 脚本不运行