This is a migrated thread and some comments may be shown as answers.

[Solved] How to unselect nodes when not a node is clicked?

3 Answers 612 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
kevin
Top achievements
Rank 1
kevin asked on 15 Dec 2014, 02:38 AM
In this example: http://demos.telerik.com/kendo-ui/treeview/api
, you can append nodes. When there is no element selected, it gets added to the tree with no parent. However, after selecting any node, doing that is no longer possible. There will always be a parent. I am aware of how to deselect all nodes programmatically:

$("#tree").data("kendoTreeView").select($());

But what I would like to do is have it such that if they click on any area within the tree that is not a node(ie, all the white space within the rectangle that isn't text), deselect the node. I've played around with various jquery selectors like :not(k-in) and :not(k-item) but haven't had any luck.

3 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 17 Dec 2014, 06:47 AM
Hello Kevin,

Clicking on any area other than the TreeView means the handler should be attached to the body or some other main page wrapping element.

e.g.

http://dojo.telerik.com/@pesho/aqOmU

Regards,
Petur Subev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
kevin
Top achievements
Rank 1
answered on 17 Dec 2014, 07:43 AM
I was hoping to have handler closer to the treeview. It's not intuitive to have to click outside of the whole tree to deselect a single node. Rather, you should just click on whitespace within the tree to deselect it. What is the selector for the "select" handler? Perhaps negating it would work? The source is obfuscated, so I can't figure it out myself.
0
Accepted
Petur Subev
Telerik team
answered on 19 Dec 2014, 07:21 AM
Hello Kevin,

You can easily modify the selector and change it according to your needs:

http://dojo.telerik.com/@pesho/aqOmU/2

Kind Regards,
Petur Subev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
TreeView
Asked by
kevin
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
kevin
Top achievements
Rank 1
Share this question
or