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

beforeSelect event

1 Answer 114 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
DDarko
Top achievements
Rank 1
DDarko asked on 20 Nov 2011, 07:09 PM
I miss the event "beforeSelect".
I would like to perform a function that will hit the server (ajax) and returns some data for the selected node. However, if the operation fails node should not be selected.
Event "beforeSelect" would be fires when I click on the node, but before the event "select". If "beforeSelect" returns False, the event "select" should not be called.


Such an event should be in other widgets.


1 Answer, 1 is accepted

Sort by
0
Accepted
Alex Gyoshev
Telerik team
answered on 21 Nov 2011, 08:59 AM

The TreeView select event is cancellable, and you can prevent the selection by calling the preventDefault method of the event arguments:

function onSelect(e) {
    if (/* business logic */) {
        e.preventDefault() // prevents the item from being selected
    }
}


If you want to request data from the server to determine whether the node can be selected, you will have to do it in a synchronous request (as the node will get selected before the async callback gets called).

Best wishes,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
TreeView
Asked by
DDarko
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Share this question
or