Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. <div class="treeView">
  2. @(Html.Kendo().TreeView()
  3. .Name("treeview")
  4. .DataTextField("Name")
  5. .DataSpriteCssClassField("Icon")
  6. .DragAndDrop(true)
  7. .DataSource(dataSource => dataSource.Read
  8. (
  9. read => read
  10. .Action("Locations", "Home"))
  11. )
  12. .LoadOnDemand(true)
  13. .Events(events => events.Select("onTreeNodeSelect").Drop("OnDrop"))
  14. )
  15. </div>
  16.  
  17. [OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
  18. public JsonResult Locations(string id, string ipAddress)
  19. {
  20. //Connects to the Given Server URL from the View - Default. Can eb removed if Default server is not required
  21. var connectionSuccess = RxMUaClient.AddServer(ControllerConstants.DefaultServer, EndpointUrl);
  22.  
  23. if (!string.IsNullOrEmpty(id))
  24. {
  25. _browseName = id;
  26. }
  27.  
  28. if (string.IsNullOrEmpty(ipAddress))
  29. {
  30. ipAddress = EndpointUrl;
  31. }
  32.  
  33. if (Session[ControllerConstants.SelectedServer] == null)
  34. {
  35. Session[ControllerConstants.SelectedServer] = ipAddress;
  36. }
  37.  
  38. ipAddress = Session[ControllerConstants.SelectedServer].ToString();
  39.  
  40. //Browse for the default "Objects" in the tree for the first time
  41. var treeNodes = RxMUaClient.BrowseTree(ipAddress, _browseName);
  42.  
  43. object locations = null;
  44.  
  45. //Prepare the Json data to display
  46. if (treeNodes != null)
  47. {
  48. locations = from e in treeNodes
  49. select new
  50. {
  51. id = e.Key,
  52. Name = e.Value.Key,
  53. URL = e.Value.Value.Key,
  54. Icon = GetIcons(ref e),
  55. hasChildren = e.Key.Any()
  56. };
  57. }
  58.  
  59. return Json(locations, JsonRequestBehavior.AllowGet);
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement