How to unselect nodes when not a node is clicked?

4 posts, 1 answers
  1. kevin
    kevin avatar
    3 posts
    Member since:
    Dec 2014

    Posted 14 Dec 2014 Link to this post

    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.
  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 17 Dec 2014 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. kevin
    kevin avatar
    3 posts
    Member since:
    Dec 2014

    Posted 17 Dec 2014 in reply to Petur Subev Link to this post

    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.
  5. Answer
    Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 19 Dec 2014 Link to this post

    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!
     
Back to Top
Kendo UI is VS 2017 Ready