This question is locked. New answers and comments are not allowed.
I know this has to be easy, but I can't seem to figure it out. I have a treeview with checkboxes and I have an onSelect client event set to call a javascript function to set the data for another treeview. I would like to check the checkbox of the selected item when I call the onSelect function. Can I do this in my javascript function? Also, for this very same javascript function, if the result returned is empty, it doesn't clear the treeview, it just leaves the nodes from the last one there. How do I clear the treeview if the result returned is empty?
Here are the treeviews:
Here's the javascript:
Your help is very much appreciated!
Thanks,
Donna
Here are the treeviews:
<%= Html.Telerik().TreeView().Name("WTGroupNames").ShowCheckBox(True).HtmlAttributes(New With {.style = "width:250px; height:550px;"}) _ .ClientEvents(Function(evt) evt.OnSelect("getUserGroupsForTaskGroup")) _ .BindTo(CType(Model.wtGoupNames, IEnumerable(Of SelectListItem)), Sub(mappings) mappings.For(Of SelectListItem)( Sub(binding) binding _ .ItemDataBound( Sub(item, linkGroup) item.Text = linkGroup.Text item.Value = linkGroup.Value item.LoadOnDemand = True End Sub) End Sub) End Sub) _ .DataBinding(Function(dataBinding) dataBinding.Ajax().Select("GetTasksForGroup", "WebTask")) %>
<%= Html.Telerik().TreeView().Name("UGsForTGs").ShowCheckBox(True).HtmlAttributes(New With {.style = "width:250px; height:550px;"}) _ .Items(Function(treeview) treeview.Add().Text("Related user groups")) _ .DataBinding(Function(dataBinding) dataBinding.Ajax().Select("GetUsersForUserGroups", "WebTask")) %> Here's the javascript:
function getUserGroupsForTaskGroup(e) { $('#usergroupsfortaskgroups').show(); var taskGroupTree = $('#WTGroupNames').data('tTreeView'); var selectedValue = taskGroupTree.getItemValue(e.item); var userGroupTree = $('#UGsForTGs'); $.post('<%= Url.Action("GetUserGroupsForTaskGroup", "WebTask") %>', // The url of the /Home/Grid action method { id: selectedValue }, // arguments which need to be passed to the Grid action method function (result, textStatus) { //JavaScript callback executed when the ajax request finishes userGroupTree.data('tTreeView').bindTo(result); // update the DIV which contains the grid }, "json" ); } Your help is very much appreciated!
Thanks,
Donna