This question is locked. New answers and comments are not allowed.
Hi, I have followed the example here:
http://www.telerik.com/support/kb/aspnet-mvc/treeview/persisting-treeview-state-in-cookie.aspx
In order to persist the expanded state between post backs.
Here is my code:
The problem is that the script:
returns the expanded node and all the text for all its children. So it returns this:
"parentchild1child2"
instead of:
"parent"
any ideas what I am missing?
Thanks
http://www.telerik.com/support/kb/aspnet-mvc/treeview/persisting-treeview-state-in-cookie.aspx
In order to persist the expanded state between post backs.
Here is my code:
@( Html.Telerik().TreeView() .Name("ApplicationTreeView") .BindTo(Model, mappings => { mappings.For<AspNet_Applications>(binding => binding .ItemDataBound((item, app) => { //item.Text = String.Format("{0}", app.ApplicationName); item.Text = app.ApplicationName; //item.Text = String.Format("{0} ({1})", app.ApplicationName, app.RoleCount); item.ImageUrl = Url.Content("~/Content/images/mailfolder.gif"); item.Expanded = ((string[])ViewData["ExpandedNodes"]).Contains(item.Text); item.Action("Index", "Admin", new {app = app.ApplicationId}); }) .Children(group => ((IEnumerable<object>) group.DistributionLists).Union ((IEnumerable<object>)group.Roles)) ); mappings.For<AspNet_Roles>(binding => binding .ItemDataBound((item, role) => { item.Text = String.Format("{0} ({1})", role.RoleName, role.UserCount); item.ImageUrl = Url.Content("~/Content/images/mailOutbox.gif"); item.Action("Index", "Admin", new { role = role.RoleId }); }).Children(role => role.ChildRoles) ); mappings.For<DistributionLists>(binding => binding .ItemDataBound((item, dl) => { item.Text = String.Format("{0}", dl.DistributionListName); item.ImageUrl = Url.Content("~/Content/images/mailPersonalFolders.gif"); item.Action("Index", "Admin", new {dl = dl.DistributionListID}); }) ); }) .ClientEvents(events => events .OnCollapse("updateTreeViewState") .OnExpand("updateTreeViewState") ) )The problem is that the script:
$(e.item).text()returns the expanded node and all the text for all its children. So it returns this:
"parentchild1child2"
instead of:
"parent"
any ideas what I am missing?
Thanks