beforeSelect event

2 posts, 1 answers
  1. DDarko
    DDarko avatar
    17 posts
    Member since:
    Oct 2011

    Posted 20 Nov 2011 Link to this post

    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.


  2. Answer
    Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2527 posts

    Posted 21 Nov 2011 Link to this post

    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!
Back to Top