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?