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

4 posts, 0 answers
  1. sarath
    sarath avatar
    3 posts
    Member since:
    Oct 2014

    Posted 21 Oct 2014 Link to this post

     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.
  2. Mihai
    Admin
    Mihai avatar
    153 posts

    Posted 22 Oct 2014 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. sarath
    sarath avatar
    3 posts
    Member since:
    Oct 2014

    Posted 27 Oct 2014 in reply to Mihai Link to this post

    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
  5. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 29 Oct 2014 Link to this post

    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!
     
Back to Top
Kendo UI is VS 2017 Ready