I have a Kendo TreeView in a Kendo window. The window is intialised and hidden on document ready
var
categoryWindow;
$(document).ready(
function
() {
categoryWindow = $(
"#category-tree"
).kendoWindow({
actions: [
"Close"
,
"Maximize"
],
draggable:
false
,
height:
"350px"
,
modal:
true
,
resizable:
false
,
title:
"Browse Document Categories"
,
width:
"500px"
,
visible:
false
}).data(
"kendoWindow"
);
});
Using fiddler I can see the child elements are being sent back by the ajax request and when I move the control outside of the window it works without any problems.
I am creating the tree using the ASP.NET MVC wrappers.
<
div
id
=
"category-tree"
>
@(Html.Kendo().TreeView()
.Name("category-treeview")
.DataTextField("Name")
.Events(e => e.Select("onTreeViewSelect"))
.DataSource(ds => ds.Read(r => r.Action("TreeView", "Categories"))))
</
div
>
8 Answers, 1 is accepted
Thank you for bringing this issue to our attention. As it turns out if the div element that holds the window is a direct child of the body element, the scripts for the TreeView are not removed from the Window content area and it is initialized twice. A workaround that I can suggest you for the moment is to wrap the div element of the window in another div, for example:
<div>
<div id=
"category-tree"
>
@(Html.Kendo().TreeView()
.Name(
"category-treeview"
)
.DataTextField(
"Name"
)
.Events(e => e.Select(
"onTreeViewSelect"
))
.DataSource(ds => ds.Read(r => r.Action(
"TreeViewRead"
,
"Home"
))))
</div>
</div>
OR
You could use the Deffered method in order to render the scripts out of the window container, for example:
<div id=
"category-tree"
>
@(Html.Kendo().TreeView()
.Name(
"category-treeview"
)
.DataTextField(
"Name"
)
.Deferred()
.Events(e => e.Select(
"onTreeViewSelect"
))
.DataSource(ds => ds.Read(r => r.Action(
"TreeViewRead"
,
"Home"
))))
</div>
@Html.Kendo().DeferredScripts()
We will fix the issue in the next release of Kendo UI. As a small sign of gratitude I am adding Telerik points to your account.
Regards,
Dimiter Madjarov
the Telerik team
I wrapping the window in a DIV as suggested, but that had no effect and I can't find a Deferred method for Treeview.
Many thanks
I prepared a sample project for you, to demonstrate the approaches, that I mentioned in my previous post.
If you are still experiencing any issues, I would suggest you to update to the latest internal Kendo UI build where the bug is already fixed.
Wish you a great day!
Dimiter Madjarov
the Telerik team
I can see all the nodes properly when i use .ExpandAll(true) which suggests that the data is bound properly from the data source, But i can neither expand or collapse nodes. Here' s the code that i used
@model IList<MvcSamplePOC_random.DataAccess.BusinessEntity>
@using Kendo.Mvc.UI.Fluent;
@{
IEnumerable<MvcSamplePOC_random.DataAccess.BusinessAssociation> assc = (IEnumerable<MvcSamplePOC_random.DataAccess.BusinessAssociation>)ViewBag.Associations;
}
@{
ViewBag.Title = "TreeView2";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>TreeView2</h2>
<div>
<div>
@(Html.Kendo().TreeView()
.Name("treeview").Deferred()
.HtmlAttributes(new { style = "width:100%;" }).ExpandAll(true)
.BindTo(Model, (NavigationBindingFactory<TreeViewItem> mappings) =>
{
mappings.For<MvcSamplePOC_random.DataAccess.BusinessEntity>(binding => binding //define first level of tree view
.ItemDataBound((item, lambdaBusinessentity) => //define mapping between panelbar item properties and the model properties
{
item.Text = lambdaBusinessentity.Name;
}).Children(lambdaBusinessentity => assc.Where(p => p.BusinessEntityId == lambdaBusinessentity.BusinessEntityId)));
mappings.For<MvcSamplePOC_random.DataAccess.BusinessAssociation>(binding => binding
.ItemDataBound((item, lambdaAssociations)=>
{
item.Text = lambdaAssociations.AssociationId.ToString();
}));
}
)
)
</div>
@Html.Kendo().DeferredScripts()
</div>
Thanks in advance
Does the problem occur with the latest internal build, too? If the nodes are not collapsible, it means that the scripts are not working for some reason. If the upgrade does not help, please submit a sample that shows the problem.
Regards,Alex Gyoshev
Telerik
I realized that the issue with some scripts not rendered properly to the web page. I have modified the references and the tree view is now expandable
Thanks
Harish
Hi, I am also facing same issue. But it is litter differ like
I am using KendoTreeView drag drop with HierarchicalDataSource. First time, when I open the modal and click on the expand icon its working fine. But when I hide the Modal and again open the modal its not expanding the node when click on plus icon.
Note: 3rd time its working fine, 4th when I opened the window its not working. Every odd time its working but Even number time its not expanding the node.
Can anyone suggest me how to fix this issue.
Hello Raja,
This thread is very old, so I assume you are referring to a different issue. Could you send us an isolated runnable example that demonstrates the problem, here or in another thread/support ticket, so we could inspect it locally and provide assistance? I am looking forward to hearing from you.
Regards,Dimiter Madjarov
Telerik