Question

Here's my tree view:

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"]
    });
}

I added the config "dataUrlField" but I'm unsure on how to configure the dataTextField "NotificationDesc" to be a hyperlink that is found IN THE API as well.

The API "../api/notifications/byuserid/" brings back the data for the tree view along with the link I need. Here's what the API returns:

<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>
...
Was it helpful?

Solution

I figured out how to do it:

$("#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");
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top