Search code examples
javascriptkendo-uikendo-treeview

Kendo TreeView onMouseOver()


I need to trigger a JavaScript method upon mousing over individual nodes within a Kendo TreeView control. Given a TreeView definition similar to the following:

$("#treeview").kendoTreeView({
    checkboxes: false,
    select: onSelect,
    expand: onExpand,
    loadOnDemand: true,
    dataSource: {
        transport: {
            read: function (options) {
                var id = options.data.id;
                var data = get(localData, id);

                if (data) {
                    options.success(data);
                } else {
                    //fetch data from server
                    }
                }
            }
        },
        schema: { model: { id: "id" } }
    }
});

How might I trigger such a mouse over event? Please note that using css hover is insufficient as I need to execute programmatic operations on hover and not just change styling.


Solution

  • I have found one solution to this. It is not incredibly direct but it is a workaround for anyone out there experiencing a similar hurdle. The following is one way to add a mouse over event to each node in a TreeView:

    var allNodes = $(".k-item");
    $.each(allNodes, function(index, node) {
        node.onmouseover = function() {
            alert("test");
       };
    }