1

返回的 JSON/XML:

<ArrayOfNode xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/DGA.Take2.WebUI.Controllers">
     <Node>
          <notificationType>NZY (1)</notificationType>
          <notifications xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
                <d3p1:string>notification1</d3p1:string>
                <d3p1:string>notification2</d3p1:string>
                <d3p1:string>notification3</d3p1:string>
          </notifications>
     </Node>
</ArrayOfNode>

我正在尝试将此树加载到 Kendo UI TreeView 中:

var notificationTypes = new kendo.data.HierarchicalDataSource({
                transport: {
                    read: {
                        url: "X"
                    }
                },
                schema: {
                    model: {
                        notificationType: "notificationType",
                        notifications: "notifications",
                        hasChildren: true,
                        string: "string"
                    }
                }
            });

            $("#treeview").kendoTreeView({
                dataSource: notificationTypes,
                checkboxes: {
                    checkChildren: true
                },
                dataTextField: ["notificationType", "notifications", "string"]
            });

这是问题所在:

4

1 回答 1

2

了解如何做到这一点:

function CreateNotificationTree(userId)
{
    debugger;
    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"],
        select: treeviewSelect
    });

    function treeviewSelect(e)
    {
        var node = this.dataItem(e.node);
        window.open(node.NotificationLink, "_self");
    }
}
于 2013-08-07T00:22:43.363 回答