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

expandPath triggers Expand event of TreeView after Read

3 Answers 405 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
CONTENTShare
Top achievements
Rank 2
CONTENTShare asked on 22 Feb 2017, 12:56 AM

Hi,

we are using TreeView with on demand loading of nodes. There is case when we need to select specific node that possibly wasn't loaded yet. So we get all needed IDs and use .expandPath expand one by one parent node of the target node. This was working fine with old 2014 kendo for mvc version. However, after switching to newest 2017.1 we are having a problem.

When .expandPath is called, we expect Expand event is called first - where we set up some values that will be used in reading of data. Then, expand would call reading of data where this prepared values are used. However, with new 2017.1 it always happens that .Data function of Read is called before Expand, which doesn't make sense for me, but could be I'm not understanding how it works.

Here are the code samples.

@(Html.Kendo().TreeView()
    .Name("treeview")
    .DataTextField("Name")
    .DataImageUrlField("image")
    .DataSource(dataSource => dataSource
        .Read(read => read
            .Action("GetFolderDefinitionsProjectsAndActs", "ProjectsCrud").Data("additionalData")
        )
    ).Events(events => events
    .Expand("onExpand").Select("onNodeSelected").DataBound("onTreeViewDataBound")
    )
)

 

function additionalData(e) {
    return {
        id: startFolderID,
        nodeType: expandLevel,
        folderDefinitionID: folderDefinitionID
    };
}

   

function onExpand(ex) {
        var tree = $('#treeview').data('kendoTreeView');
        var dataItem = tree.dataItem(ex.node);
        expandLevel = dataItem.levelName;
        folderDefinitionID = dataItem.FolderDefinitionID;
        return true;
    }

 

So, at some point we call

var treeview = $("#treeview").data("kendoTreeView");
treeview.expandPath(returnData);

and we would expect function onExpand to be called before additionalData, but instead additionalData is called before onExpand.

Is this expected behavior?

3 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Danchev
Telerik team
answered on 22 Feb 2017, 08:12 AM
Hello Nikola,

Indeed there has been a change in the order of calling the data source's read data function and the expand event and it happened in Q1 2016 SP2 (version 2016.1.406). Since this Kendo UI version the data function is called first and then the expand event fires. This change is related to several bug fixes with regard to the expandPath method, described in the release notes for this particular release.

Regards,
Ivan Danchev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
CONTENTShare
Top achievements
Rank 2
answered on 22 Feb 2017, 11:07 AM

Hello Ivan,

thank you for clarifying this. So we now do everything in .Data function instead in .Expand and it is OK, we just didn't expected this new order of things.

Best Regards

0
Ivan Danchev
Telerik team
answered on 24 Feb 2017, 09:44 AM
Hello Nikola,

I am glad you made it work in the data function. Indeed this change in the order of event firing/function calling has not been documented, which can cause confusion with regard to what the actual expected behavior is. We are doing our best to avoid such cases and document all changes (breaking or not).

Regards,
Ivan Danchev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
TreeView
Asked by
CONTENTShare
Top achievements
Rank 2
Answers by
Ivan Danchev
Telerik team
CONTENTShare
Top achievements
Rank 2
Share this question
or