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

Node Select Cancel - Focus

2 Answers 733 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 30 Oct 2015, 07:01 PM
In my TreeView, while I have a node selected and I click another node in the tree, if I cancel the select via "e.preventDefault()" in my Select event handler, the selection is cancelled but the node I clicked retains focus.  Is there a way of preventing this (removing focus from the node I clicked)?  I tried adding code to remove the "k-state-focused" class from the node, but it does not work...

e.preventDefault();
$("#treeview_tv_active span.k-state-focused").removeClass("k-state-focused");

Thanks.

2 Answers, 1 is accepted

Sort by
0
Accepted
Konstantin Dikov
Telerik team
answered on 03 Nov 2015, 12:57 PM
Hello Dave,

Thank you for contacting Telerik Support.

In order to remove the focused styles from the clicked item you should wrap the code for removing the k-state-focused class within a setTimeout function:
$("#treeview").kendoTreeView({
    select: function (e) {
        e.preventDefault();
        setTimeout(function () {
            $(e.node).find(".k-state-focused").removeClass("k-state-focused");
        })
    }
});

Could you please give the above approach a try and let me know if the result meets your exact requirements.

I am looking forward to your reply.


Regards,
Konstantin Dikov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Dave
Top achievements
Rank 1
answered on 03 Nov 2015, 03:40 PM
Yes, that seemed to work.  Thank you!
Tags
TreeView
Asked by
Dave
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Dave
Top achievements
Rank 1
Share this question
or