Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="treeView">
- @(Html.Kendo().TreeView()
- .Name("treeview")
- .DataTextField("Name")
- .DataSpriteCssClassField("Icon")
- .DragAndDrop(true)
- .DataSource(dataSource => dataSource.Read
- (
- read => read
- .Action("Locations", "Home"))
- )
- .LoadOnDemand(true)
- .Events(events => events.Select("onTreeNodeSelect").Drop("OnDrop"))
- )
- </div>
- [OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
- public JsonResult Locations(string id, string ipAddress)
- {
- //Connects to the Given Server URL from the View - Default. Can eb removed if Default server is not required
- var connectionSuccess = RxMUaClient.AddServer(ControllerConstants.DefaultServer, EndpointUrl);
- if (!string.IsNullOrEmpty(id))
- {
- _browseName = id;
- }
- if (string.IsNullOrEmpty(ipAddress))
- {
- ipAddress = EndpointUrl;
- }
- if (Session[ControllerConstants.SelectedServer] == null)
- {
- Session[ControllerConstants.SelectedServer] = ipAddress;
- }
- ipAddress = Session[ControllerConstants.SelectedServer].ToString();
- //Browse for the default "Objects" in the tree for the first time
- var treeNodes = RxMUaClient.BrowseTree(ipAddress, _browseName);
- object locations = null;
- //Prepare the Json data to display
- if (treeNodes != null)
- {
- locations = from e in treeNodes
- select new
- {
- id = e.Key,
- Name = e.Value.Key,
- URL = e.Value.Value.Key,
- Icon = GetIcons(ref e),
- hasChildren = e.Key.Any()
- };
- }
- return Json(locations, JsonRequestBehavior.AllowGet);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement