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

Is there any way to get the dataItem of current expanded node using onExpand event?

3 Answers 551 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
sarath
Top achievements
Rank 1
sarath asked on 21 Oct 2014, 02:52 PM
 I would like to get the dataItem onExpand of the node. I am using AngularJs Kendo treeGrid<div kendo-tree-view="tree"
             k-data-source="treeData"
             k-template="itemTemplate"
             k-on-expand="onExpand(selected, data, dataItem, columns)"></div>

<!-- angular module -->
angular.module("KendoDemos", [ "kendo.directives" ]);
function MyCtrl($scope) {
           $scope.onExpand = function(selected, data, dataItem, columns) {
           <!-- Here I would like to get the current dataItem. The dataItem as a parameter is coming as undefined. -->
           alert('onExpand ' + e); 
      }
}

Here data-Item represents the current selected node dataSource value.

3 Answers, 1 is accepted

Sort by
0
Mihai
Telerik team
answered on 22 Oct 2014, 10:18 AM
Hello,

The dataItem is available only for k-on-change events.  However, for expand you can easily get it from the kendoEvent.  Note that there is a distinction between selected item and expanded item -- a tree allows you to select an item, and expand a different item.  Hope these samples clarify:

1. for Tree: http://dojo.telerik.com/@mishoo/udidI/2
2. for Grid: http://dojo.telerik.com/@mishoo/okEQe

I included the grid sample because it's not really clear to me if you're using a tree or a grid.  But in any case, getting at the expanded element is similar for both: call widget.dataItem(domNode), where domNode is the expanded element which you get via kendoEvent.  For tree that's ev.node, and for grid it's ev.masterRow.

Hope this helps.

Regards,
Mihai
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
sarath
Top achievements
Rank 1
answered on 27 Oct 2014, 12:48 PM
Hello Mihai,
    Thanks for your reply. I am able to get the expanded node onClick of expand. I am using tree widget. Now after getting the current expanded node, I would like to make a HTTP Post request to the server, which will get the childNodes and have to append the items.
 
Here is my sample code:
http://dojo.telerik.com/EvuSA

Thanks & Regards
Sarath U
0
Alex Gyoshev
Telerik team
answered on 29 Oct 2014, 08:51 AM
Hello Sarath,

Are you by any chance trying to implement load on demand? If so you can use the out-of-the-box support for remote loading, as shown in this example.

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