TreeView Check event handler: how to get check status and field values?

4 posts, 0 answers
  1. Scott
    Scott avatar
    28 posts
    Member since:
    May 2015

    Posted 02 Nov 2015 Link to this post

     The treeview events demo has event handlers such as the following:

             function onCheck(e) {

                      kendoConsole.log("Checkbox changed :: " + this.text(e.node));

                      //???????  do something useful  ?????

             }

    But how would I do something useful, like get ID, checked status (checked or unchecked), or other fields of the item checked?

    If the data source has model with fields "Id", "name", "something", how would I get those values?

  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 04 Nov 2015 Link to this post

    Hello Scott,

     

    In order to get the data item associated with the node DOM element you can use the dataItem method of the Kendo UI TreeView. Once you have access to the data item object you can access the model fields and etc. 

     

    Also checked field of the data item returns the state of the check box element for the node. 

     

    Regards,
    Boyan Dimitrov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Scott
    Scott avatar
    28 posts
    Member since:
    May 2015

    Posted 04 Nov 2015 in reply to Boyan Dimitrov Link to this post

    Something like this?

    function onPrivilegeCheck(e) { 

        var treeView = $("#myTreeView").data("kendoTreeView"); // how to get treeview object, if named "myTreeView"
        var nodeData = treeView.dataItem(e.node); // get an object representing the data of the node that was checked(triggering this event)

        var checkedStatus = nodeData.checked; // get the checked status of that node

    //do something useful here

    }

  5. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 06 Nov 2015 Link to this post

    Hello Scott,

     

    Yes indeed and the onPrivilegeCheck function should be handler for the check event of the Kendo UI TreeView. 

     

    Regards,
    Boyan Dimitrov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET MVC is VS 2017 Ready