mick_000
mick_000

Reputation: 69

Unable to deselect the selected node in KendoUI tree view

I have a tree-like structure using Kendo UI tree view. Each node is displayed as a hyperlink and on clicking each one, a new kendotabstrip will be opened. My problem is if I select one node, the results are displayed fine in a new tab but if I close the newly opened tab and then select the same node then no new tab is opened since the node has already been selected. If I have to choose the same node, then I have to access another node and then come back to node.

I tried to deselect the selected item once the new tab is opened using the following snippet:

var treeview=$(#grpTree).data("KendoTreeView");

var selNode=treeview.select(); 

selNode.find("span.k-state-selected").removeClass("k-state-selected")

but the node is not getting deselected. Is there any other way to do it or have I missed out anything?

Upvotes: 4

Views: 5738

Answers (4)

nosaxw
nosaxw

Reputation: 11

My code:

var treeview=$(#grpTree).data("KendoTreeView");

treeview.select(null);

Upvotes: 1

Selim Reza
Selim Reza

Reputation: 1084

This calls the change function always, so this can be another solution:

    $("#favorite_tree").kendoTreeView({
change: function () {
    if (this.dataItem(this.select())) {
        var treeView = $("#calendar_tree").data("kendoTreeView");
        treeView.select($());
    }
}
}).data('kendoTreeView');

$("#calendar_tree").kendoTreeView({
change: function () {
    if (this.dataItem(this.select())) {
        var treeView = $("#favorite_tree").data("kendoTreeView");
        treeView.select($());
    }
 }
}).data('kendoTreeView');    

Upvotes: 0

Jark Monster
Jark Monster

Reputation: 763

I know this post is a bit dated, but as Telerik is continually upgrading its components, I thought I'd put this here so that people can be aware of this change moving forward.

You can deselect all selected nodes with the following syntax:

    var treeView = $("#treeView").data("kendoTreeView");
    treeView.select($());

Source: Kendo UI Treeview Documentation for Select

Upvotes: 8

Petur Subev
Petur Subev

Reputation: 20193

Yes this is by design. If you want to attach a click handler which will be triggered each time (no matter if the node is already selected). You can attach a delegate event like the following:

$('#treeviewName').on('click','.k-item',function(e){
      var clickedNode = $(this);
      var treeViewClientObject = $(e.delegateTarget).data().kendoTreeView;
})

Upvotes: 1

Related Questions