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

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

3 Answers 591 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 03 Nov 2015, 12:23 AM

 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?

3 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 04 Nov 2015, 12:47 PM

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
0
Scott
Top achievements
Rank 1
answered on 04 Nov 2015, 09:21 PM

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

}

0
Boyan Dimitrov
Telerik team
answered on 06 Nov 2015, 01:03 PM

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
Tags
TreeView
Asked by
Scott
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Scott
Top achievements
Rank 1
Share this question
or